From b704168e9c6b21d8ab1bf2e25ffa8fcae26010d1 Mon Sep 17 00:00:00 2001 From: Alexander Rosenberg Date: Fri, 17 Nov 2023 22:07:06 -0800 Subject: [PATCH] Fix locking in swayidle-lock-screen --- swayidle-lock-screen | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/swayidle-lock-screen b/swayidle-lock-screen index c900d8e..88daa63 100755 --- a/swayidle-lock-screen +++ b/swayidle-lock-screen @@ -1,6 +1,12 @@ #!/usr/bin/env zsh +LOCKFILE="${HOME}/.cache/swayidle-lock-screen.lock" + function run { + # ensure multiple instances do not run + mkdir -p "$(dirname "${LOCKFILE}")" + exec 4<>"${LOCKFILE}" + flock -n 4 || exit 0 dunstctl set-paused true swayidle -w -C /dev/null \ timeout 15 'hyprctl dispatch dpms off' resume 'hyprctl dispatch dpms on' & @@ -10,6 +16,7 @@ function run { hyprctl dispatch dpms on dunstctl set-paused false fix_eww + flock -u 4 } function fix_eww {