Fix locking in swayidle-lock-screen

This commit is contained in:
Alexander Rosenberg 2023-11-17 22:07:06 -08:00
parent c41505e26c
commit b704168e9c
Signed by: Zander671
GPG Key ID: 5FD0394ADBD72730

View File

@ -1,6 +1,12 @@
#!/usr/bin/env zsh #!/usr/bin/env zsh
LOCKFILE="${HOME}/.cache/swayidle-lock-screen.lock"
function run { function run {
# ensure multiple instances do not run
mkdir -p "$(dirname "${LOCKFILE}")"
exec 4<>"${LOCKFILE}"
flock -n 4 || exit 0
dunstctl set-paused true dunstctl set-paused true
swayidle -w -C /dev/null \ swayidle -w -C /dev/null \
timeout 15 'hyprctl dispatch dpms off' resume 'hyprctl dispatch dpms on' & timeout 15 'hyprctl dispatch dpms off' resume 'hyprctl dispatch dpms on' &
@ -10,6 +16,7 @@ function run {
hyprctl dispatch dpms on hyprctl dispatch dpms on
dunstctl set-paused false dunstctl set-paused false
fix_eww fix_eww
flock -u 4
} }
function fix_eww { function fix_eww {