3 # Example locker script -- demonstrates how to use the --transfer-sleep-lock
4 # option with i3lock's forking mode to delay sleep until the screen is locked.
6 ## CONFIGURATION ##############################################################
8 # Options to pass to i3lock
9 i3lock_options="-c 000000"
11 # Run before starting the locker
17 # Run after the locker exits
22 ###############################################################################
26 # We set a trap to kill the locker if we get killed, then start the locker and
27 # wait for it to exit. The waiting is not that straightforward when the locker
28 # forks, so we use this polling only if we have a sleep lock to deal with.
29 if [[ -e /dev/fd/${XSS_SLEEP_LOCK_FD:--1} ]]; then
31 pkill -xu $EUID "$@" i3lock
34 trap kill_i3lock TERM INT
36 # we have to make sure the locker does not inherit a copy of the lock fd
37 i3lock $i3lock_options {XSS_SLEEP_LOCK_FD}<&-
39 # now close our fd (only remaining copy) to indicate we're ready to sleep
40 exec {XSS_SLEEP_LOCK_FD}<&-
42 while kill_i3lock -0; do
46 trap 'kill %%' TERM INT
47 i3lock -n $i3lock_options &