xss-lock: use a dimmer service to start/stop dimmer

This way, we can lock the screen before stopping dimmer.
This commit is contained in:
Vincent Bernat 2021-08-04 08:21:27 +02:00
parent 8d70ce8106
commit 3d9c3e458c
2 changed files with 12 additions and 3 deletions

View file

@ -12,6 +12,9 @@ unconfigure() {
xset s 0
xset dpms 0 0 0
}
dimmer() {
systemctl --user $1 dimmer@$notify.service
}
case "$1" in
start)
@ -20,9 +23,10 @@ case "$1" in
;;
dim|notify)
echo "notify: start (idle: $(xprintidle))"
trap 'echo notify: user activity; kill %% 2> /dev/null; exit 0' HUP # user activity
trap 'echo notify: user activity; dimmer stop; kill %% 2> /dev/null; exit 0' HUP # user activity
trap 'echo notify: locker started; kill %% 2> /dev/null; exit 0' TERM # locker started
~/.config/i3/bin/dimmer --delay $notify &
dimmer start
sleep infinity &
wait
echo "notify: end"
;;
@ -36,7 +40,7 @@ case "$1" in
# Then, lock screen
i3lock -n -e -i $HOME/.cache/i3/current-wallpaper.png -t -f
echo "lock: unlock screen"
# Resume notifications
dimmer stop
dunstctl set-paused false
;;
esac

View file

@ -0,0 +1,5 @@
[Unit]
Description=Screen dimmer
[Service]
ExecStart=%h/.config/i3/bin/dimmer --delay=%i