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-24 19:55:19 +01:00
|
|
|
redshift=$(systemctl --user show \
|
|
|
|
--property MainPID \
|
|
|
|
--value redshift@$(systemd-escape -- "$DISPLAY").service)
|
|
|
|
[ x$redshift = x ] || kill -STOP $redshift
|
2020-01-24 19:59:40 +01:00
|
|
|
trap "[ x$redshift = x ] || kill -CONT $redshift" EXIT
|
2020-01-24 19:18:18 +01:00
|
|
|
trap 'kill %% 2> /dev/null; exit 0' HUP # user activity
|
|
|
|
trap 'sleep 0.2s; kill %% 2> /dev/null; exit 0' TERM # locker started
|
2020-01-24 19:59:40 +01:00
|
|
|
outputs=($(xrandr -q | sed -n 's/\([^ ]*\) connected .*/\1/p'))
|
2020-01-19 18:06:06 +01:00
|
|
|
for i in $(seq 0.7 -0.01 0.1); do
|
2020-01-24 19:59:40 +01:00
|
|
|
for out in ${outputs[@]}; do
|
|
|
|
xrandr --output $out --brightness $i || \
|
|
|
|
outputs=("${outputs[@]/$out}")
|
|
|
|
done
|
|
|
|
sleep 0.1
|
2020-01-19 18:06:06 +01:00
|
|
|
done
|
2020-01-19 21:05:23 +01:00
|
|
|
echo "notify: end"
|
2020-01-19 18:06:06 +01:00
|
|
|
sleep infinity &
|
2014-09-12 14:52:36 +02:00
|
|
|
wait
|
|
|
|
;;
|
|
|
|
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
|