locking xscreensaver before suspending

11 July 2018 config

xscreensaver takes a little duration when resuming to lock the screen. to fix this, the screen has to be locked before pm-suspend is called.

#!/bin/sh
# Default acpi script that takes an entry for all actions

IFS=${IFS}/
set $@

case "$1" in
button)
case "$2" in
power) /sbin/init 0
 ;;
sleep) 
    sudo -u "#$(cat /proc/$(pgrep xscreensaver)/status | grep Uid | cut -f 2)" xscreensaver-command -lock
    sleep 1
    pm-suspend
 ;;
*) logger "ACPI action $2 is not defined"
 ;;
esac
;;
*)
logger "ACPI group $1 / action $2 is not defined"
;;
esac