In X I've used the following script (from here) to lock the computer with i3lock each time pm-suspend or pm-hibernate are invoked.
/etc/pm/sleep.d/00screensaver-lock:
#!/bin/sh
# 00screensaver-lock: lock workstation on hibernate or suspend
username=andreas
userhome=/home/$username
export XAUTHORITY="$userhome/.Xauthority"
export DISPLAY=":0"
case "$1" in
hibernate|suspend)
su $username -c "/usr/bin/i3lock &
;;
thaw|resume)
;;
*) exit $NA
;;
esac
Now I'm in the process of setting up a console-only laptop (a minimal Debian install without the X server installed.)
I've tried using the above script on that machine to lock my session using vlock. (That is: I've switched out i3lock with vlock in the version of the script I'm using on the console machine.) I've also tried commenting out the two lines starting with export XAUTHORITY and export DISPLAY=":0" as they are X specific.
The script doesn't work on the no-X machine.
How should I call vlock each time the computer suspends/hibernates?