2014-09-12 14:52:36 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2020-01-20 15:06:28 +01:00
|
|
|
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))
|
2020-02-07 09:58:02 +01:00
|
|
|
display=$(systemd-escape -- "$DISPLAY")
|
2014-09-12 14:52:36 +02:00
|
|
|
|
2019-12-08 12:23:51 +01:00
|
|
|
configure() {
|
|
|
|
xset s $((timeout - notify)) $notify
|
2021-02-22 15:46:55 +01:00
|
|
|
xset dpms $((timeout * 2)) $((timeout * 22 / 10)) $((timeout * 24 / 10))
|
2019-12-08 12:23:51 +01:00
|
|
|
}
|
2019-12-08 15:40:11 +01:00
|
|
|
unconfigure() {
|
|
|
|
xset s 0
|
|
|
|
xset dpms 0 0 0
|
|
|
|
}
|
2019-12-08 12:23:51 +01:00
|
|
|
|
2014-09-12 14:52:36 +02:00
|
|
|
case "$1" in
|
|
|
|
start)
|
2019-12-08 12:23:51 +01:00
|
|
|
configure
|
2020-02-08 17:53:12 +01:00
|
|
|
exec xss-lock --session=${XDG_SESSION_ID} --notifier="$me notify" --transfer-sleep-lock "$me" lock
|
2014-09-12 14:52:36 +02:00
|
|
|
;;
|
2014-09-14 18:55:57 +02:00
|
|
|
dim|notify)
|
2020-11-18 09:49:08 +01:00
|
|
|
echo "notify: start (idle: $(xprintidle))"
|
2020-02-07 09:58:02 +01:00
|
|
|
systemctl --user kill -s STOP redshift@${display}.service
|
|
|
|
trap "systemctl --user kill -s CONT redshift@${display}.service" EXIT
|
2020-01-24 21:54:03 +01:00
|
|
|
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
|
2021-07-15 15:14:39 +02:00
|
|
|
outputs=($(xrandr --current | sed -n 's/\([^ ]*\) connected .*/\1/p'))
|
|
|
|
for out in ${outputs[@]}; do
|
|
|
|
xrandr --output $out --brightness 0.2
|
|
|
|
done
|
2020-01-24 23:02:07 +01:00
|
|
|
sleep infinity &
|
2014-09-12 14:52:36 +02:00
|
|
|
wait
|
2020-01-24 21:54:03 +01:00
|
|
|
echo "notify: end"
|
2014-09-12 14:52:36 +02:00
|
|
|
;;
|
|
|
|
lock)
|
2020-11-18 09:49:08 +01:00
|
|
|
echo "lock: lock screen (idle: $(xprintidle))"
|
2019-12-08 12:23:51 +01:00
|
|
|
# Something may have mendled with screensaver settings
|
|
|
|
configure
|
2021-07-07 18:55:50 +02:00
|
|
|
# Pause music player and notifications
|
2020-09-24 21:21:32 +02:00
|
|
|
playerctl -a pause
|
2021-07-07 18:54:18 +02:00
|
|
|
dunstctl set-paused true
|
2021-07-07 18:55:50 +02:00
|
|
|
# Then, lock screen
|
2021-07-03 14:13:56 +02:00
|
|
|
i3lock -n -e -i $HOME/.cache/i3/current-wallpaper.png -t -f
|
2020-01-19 21:05:23 +01:00
|
|
|
echo "lock: unlock screen"
|
2021-07-07 18:55:50 +02:00
|
|
|
# Resume notifications
|
|
|
|
dunstctl set-paused false
|
2014-09-12 14:52:36 +02:00
|
|
|
;;
|
|
|
|
esac
|