transfer-sleep-slock.sh (1132B)
1 #!/bin/bash 2 3 # script for xss-lock 4 5 # Example locker script -- demonstrates how to use the --transfer-sleep-lock 6 # option with a fixed delay to give simple lockers a little bit of time to lock 7 # the screen before the system goes the sleep. 8 9 ## CONFIGURATION ############################################################## 10 11 # Command to start the locker (should not fork) 12 locker="slock" 13 14 # Delay in seconds. Note that by default systemd-logind allows a maximum sleep 15 # delay of 5 seconds. 16 sleep_delay=1 17 18 # Run before starting the locker 19 pre_lock() { 20 #mpc pause 21 return 22 } 23 24 # Run after the locker exits 25 post_lock() { 26 return 27 } 28 29 ############################################################################### 30 31 pre_lock 32 33 # kill locker if we get killed 34 trap 'kill %%' TERM INT 35 36 if [[ -e /dev/fd/${XSS_SLEEP_LOCK_FD:--1} ]]; then 37 # lock fd is open, make sure the locker does not inherit a copy 38 $locker {XSS_SLEEP_LOCK_FD}<&- & 39 40 sleep $sleep_delay 41 42 # now close our fd (only remaining copy) to indicate we're ready to sleep 43 exec {XSS_SLEEP_LOCK_FD}<&- 44 else 45 $locker & 46 fi 47 48 wait # for locker to exit 49 50 post_lock