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

59 lines
2.1 KiB
Text
Raw Normal View History

#!/bin/bash
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))
configure() {
xset s $((timeout - notify)) $notify
xset dpms $((timeout * 3)) $((timeout * 32 / 10)) $((timeout * 34 / 10))
}
dimmer() {
systemctl --user --no-block $1 xss-dimmer@$notify.service
}
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; dimmer stop; kill %% 2> /dev/null; exit 0' HUP # user activity
trap 'echo notify: locker started; kill %% 2> /dev/null; exit 0' TERM # locker started
dimmer start
sleep infinity &
wait
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_state=$(dunstctl is-paused)
dunstctl set-paused true
2021-07-07 18:55:50 +02:00
# Then, lock screen
env XSECURELOCK_SAVER=$HOME/.config/i3/bin/xsecurelock-saver \
`# Disable Randr 1.5 support to make screensaver spans accross the whole monitor` \
XSECURELOCK_NO_XRANDR15=1 \
`# Delay mapping saver window by 500ms to give some time to saver to start` \
XSECURELOCK_SAVER_DELAY_MS=500 \
`# Do not kill screensaver when DPMS is enabled` \
XSECURELOCK_SAVER_STOP_ON_DPMS=0 \
`# 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` \
XSECURELOCK_FONT="Iosevka" \
`# Timeout for authentication window` \
XSECURELOCK_AUTH_TIMEOUT=10 \
xsecurelock
echo "lock: unlock screen"
2021-08-04 11:44:21 +02:00
# After unlocking screen, stop dimmer, restore notifications
dimmer stop
dunstctl set-paused ${dunstctl_state}
;;
esac