1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#!/usr/bin/env bash if [[ -e "/dev/fd/${XSS_SLEEP_LOCK_FD:--1}" ]]; then pid="$(slock -kfp {XSS_SLEEP_LOCK_FD}<&-)" trap "kill ${pid}" TERM INT exec {XSS_SLEEP_LOCK_FD}<&- waitpid "${pid}" & wait else trap 'kill %%' TERM INT slock -k & wait fi