2014-09-12 14:52:36 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2020-01-20 15:06:28 +01:00
|
|
|
me="$(readlink -f "$0")"
|
2021-09-08 22:31:23 +02:00
|
|
|
timeout=300
|
2021-09-24 09:46:31 +02:00
|
|
|
notify=$((timeout/10))
|
2014-09-12 14:52:36 +02:00
|
|
|
|
2019-12-08 12:23:51 +01:00
|
|
|
configure() {
|
|
|
|
xset s $((timeout - notify)) $notify
|
2022-02-17 16:08:31 +01:00
|
|
|
xset dpms $((timeout * 3)) $((timeout * 32 / 10)) $((timeout * 34 / 10))
|
2019-12-08 12:23:51 +01:00
|
|
|
}
|
2021-08-04 08:21:27 +02:00
|
|
|
dimmer() {
|
2022-05-12 10:25:50 +02:00
|
|
|
systemctl --user --no-block $1 xss-dimmer@$notify.service
|
2021-08-04 08:21:27 +02:00
|
|
|
}
|
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))"
|
2021-08-04 08:21:27 +02:00
|
|
|
trap 'echo notify: user activity; dimmer stop; kill %% 2> /dev/null; exit 0' HUP # user activity
|
2020-01-24 21:54:03 +01:00
|
|
|
trap 'echo notify: locker started; kill %% 2> /dev/null; exit 0' TERM # locker started
|
2021-08-04 08:21:27 +02:00
|
|
|
dimmer start
|
|
|
|
sleep infinity &
|
2021-08-04 00:32:17 +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))"
|
2021-07-15 20:54:22 +02:00
|
|
|
# Something may have meddled with screensaver settings
|
2019-12-08 12:23:51 +01:00
|
|
|
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
|
2022-10-06 11:44:00 +02:00
|
|
|
dunstctl_state=$(dunstctl is-paused)
|
2021-07-07 18:54:18 +02:00
|
|
|
dunstctl set-paused true
|
2021-07-07 18:55:50 +02:00
|
|
|
# Then, lock screen
|
2021-12-07 20:34:15 +01:00
|
|
|
env XSECURELOCK_SAVER=$HOME/.config/i3/bin/xsecurelock-saver \
|
2021-12-26 12:32:18 +01:00
|
|
|
`# Disable Randr 1.5 support to make screensaver spans accross the whole monitor` \
|
2021-12-07 20:34:15 +01:00
|
|
|
XSECURELOCK_NO_XRANDR15=1 \
|
2021-12-26 12:32:18 +01:00
|
|
|
`# Delay mapping saver window by 500ms to give some time to saver to start` \
|
2021-12-08 21:13:43 +01:00
|
|
|
XSECURELOCK_SAVER_DELAY_MS=500 \
|
2022-08-14 20:31:44 +02:00
|
|
|
`# Do not kill screensaver when DPMS is enabled` \
|
|
|
|
XSECURELOCK_SAVER_STOP_ON_DPMS=0 \
|
2021-12-26 12:32:18 +01:00
|
|
|
`# Image and text for saver` \
|
|
|
|
XSECURELOCK_SAVER_IMAGE=$XDG_RUNTIME_DIR/i3/current-wallpaper.png \
|
|
|
|
XSECURELOCK_SAVER_WEATHER=$XDG_RUNTIME_DIR/i3/weather.txt \
|
|
|
|
`# Font for authentication window` \
|
2021-12-07 20:34:15 +01:00
|
|
|
XSECURELOCK_FONT="Iosevka" \
|
2021-12-26 12:32:18 +01:00
|
|
|
`# Timeout for authentication window` \
|
2021-12-09 08:35:23 +01:00
|
|
|
XSECURELOCK_AUTH_TIMEOUT=10 \
|
2021-12-07 20:34:15 +01:00
|
|
|
xsecurelock
|
2020-01-19 21:05:23 +01:00
|
|
|
echo "lock: unlock screen"
|
2021-08-04 11:44:21 +02:00
|
|
|
# After unlocking screen, stop dimmer, restore notifications
|
2021-08-04 08:21:27 +02:00
|
|
|
dimmer stop
|
2022-10-06 11:44:00 +02:00
|
|
|
dunstctl set-paused ${dunstctl_state}
|
2014-09-12 14:52:36 +02:00
|
|
|
;;
|
|
|
|
esac
|