2014-09-12 14:52:36 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2020-01-20 15:06:28 +01:00
|
|
|
me="$(readlink -f "$0")"
|
2015-06-17 08:46:28 +02:00
|
|
|
timeout=300
|
2014-09-12 21:23:15 +02:00
|
|
|
notify=10
|
2014-09-12 14:52:36 +02:00
|
|
|
|
2019-12-08 12:23:51 +01:00
|
|
|
configure() {
|
|
|
|
xset s $((timeout - notify)) $notify
|
|
|
|
xset dpms $((timeout * 3)) $((timeout * 4)) $((timeout * 5))
|
|
|
|
}
|
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-01-20 15:06:28 +01:00
|
|
|
exec xss-lock -s ${XDG_SESSION_ID} -n "$me notify" -l $me lock
|
2014-09-12 14:52:36 +02:00
|
|
|
;;
|
2014-09-14 18:55:57 +02:00
|
|
|
dim|notify)
|
2020-01-19 21:05:23 +01:00
|
|
|
echo "notify: start"
|
2020-01-25 14:38:19 +01:00
|
|
|
systemctl --user kill -s STOP redshift@$(systemd-escape -- "$DISPLAY").service
|
|
|
|
trap "systemctl --user kill -s CONT redshift@$(systemd-escape -- "$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
|
2020-01-29 11:16:05 +01:00
|
|
|
outputs=($(xrandr --current | sed -n 's/\([^ ]*\) connected .*/\1/p'))
|
2020-01-24 23:02:07 +01:00
|
|
|
for out in ${outputs[@]}; do
|
|
|
|
xrandr --output $out --brightness 0.2
|
|
|
|
done
|
|
|
|
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)
|
2019-12-08 12:23:51 +01:00
|
|
|
# Something may have mendled with screensaver settings
|
|
|
|
configure
|
2015-07-12 21:54:03 +02:00
|
|
|
# First, stop any music player
|
|
|
|
xdotool key XF86AudioStop
|
2014-12-11 08:32:21 +01:00
|
|
|
# Then, lock screen
|
2020-01-19 21:05:23 +01:00
|
|
|
echo "lock: lock screen"
|
2020-01-19 18:36:36 +01:00
|
|
|
systemctl --user stop compton@$(systemd-escape -- "$DISPLAY").service
|
2016-06-06 10:20:15 +02:00
|
|
|
i3lock -n -e -i $HOME/.cache/awesome/current-wallpaper.png -t -f
|
2020-01-19 18:36:36 +01:00
|
|
|
systemctl --user start compton@$(systemd-escape -- "$DISPLAY").service
|
2020-01-19 21:05:23 +01:00
|
|
|
echo "lock: unlock screen"
|
2014-09-12 14:52:36 +02:00
|
|
|
;;
|
|
|
|
esac
|