xss-lock: correctly stop redshift

This commit is contained in:
Vincent Bernat 2021-07-15 20:54:22 +02:00
parent 0f4e668b51
commit ae6e89e27e

View file

@ -3,7 +3,6 @@
me="$(readlink -f "$0")" me="$(readlink -f "$0")"
timeout=600 timeout=600
notify=$((timeout/30)) notify=$((timeout/30))
display=$(systemd-escape -- "$DISPLAY")
configure() { configure() {
xset s $((timeout - notify)) $notify xset s $((timeout - notify)) $notify
@ -21,8 +20,8 @@ case "$1" in
;; ;;
dim|notify) dim|notify)
echo "notify: start (idle: $(xprintidle))" echo "notify: start (idle: $(xprintidle))"
systemctl --user kill -s STOP redshift@${display}.service systemctl --user kill -s STOP redshift.service
trap "systemctl --user kill -s CONT redshift@${display}.service" EXIT trap "systemctl --user kill -s CONT redshift.service" EXIT
trap 'echo notify: user activity; kill %% 2> /dev/null; exit 0' HUP # user activity trap 'echo notify: user activity; kill %% 2> /dev/null; exit 0' HUP # user activity
trap 'echo notify: locker started; kill %% 2> /dev/null; exit 0' TERM # locker started trap 'echo notify: locker started; kill %% 2> /dev/null; exit 0' TERM # locker started
outputs=($(xrandr --current | sed -n 's/\([^ ]*\) connected .*/\1/p')) outputs=($(xrandr --current | sed -n 's/\([^ ]*\) connected .*/\1/p'))
@ -35,7 +34,7 @@ case "$1" in
;; ;;
lock) lock)
echo "lock: lock screen (idle: $(xprintidle))" echo "lock: lock screen (idle: $(xprintidle))"
# Something may have mendled with screensaver settings # Something may have meddled with screensaver settings
configure configure
# Pause music player and notifications # Pause music player and notifications
playerctl -a pause playerctl -a pause