vincentbernat.i3wm-configur.../bin/xss-lock

42 lines
1.2 KiB
Text
Raw Normal View History

#!/bin/bash
me="$(readlink -f "$0")"
2021-01-03 11:15:13 +01:00
timeout=600
2021-01-23 11:50:49 +01:00
notify=$((timeout/30))
configure() {
xset s $((timeout - notify)) $notify
2021-02-22 15:46:55 +01:00
xset dpms $((timeout * 2)) $((timeout * 22 / 10)) $((timeout * 24 / 10))
}
unconfigure() {
xset s 0
xset dpms 0 0 0
}
case "$1" in
start)
configure
2020-02-08 17:53:12 +01:00
exec xss-lock --session=${XDG_SESSION_ID} --notifier="$me notify" --transfer-sleep-lock "$me" lock
;;
dim|notify)
echo "notify: start (idle: $(xprintidle))"
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
~/.config/i3/bin/dimmer --delay $notify
echo "notify: end"
;;
lock)
echo "lock: lock screen (idle: $(xprintidle))"
2021-07-15 20:54:22 +02:00
# Something may have meddled with screensaver settings
configure
2021-07-07 18:55:50 +02:00
# Pause music player and notifications
playerctl -a pause
dunstctl set-paused true
2021-07-07 18:55:50 +02:00
# Then, lock screen
i3lock -n -e -i $HOME/.cache/i3/current-wallpaper.png -t -f
echo "lock: unlock screen"
2021-07-07 18:55:50 +02:00
# Resume notifications
dunstctl set-paused false
;;
esac