Run User Scripts on Suspend and Wakeup on Void Linux
Posted by Dave Eddy on Oct 01 2018 - tags: techWhile using Void Linux on my laptop, I wanted some way to trigger scripts as my user when the machine went to sleep and when it resumed. The main goal of this was to be able to lock my machine using i3lock on suspend.
I currently use xss-lock to register i3lock
to be called whenever
the screensaver is activated with this command (run at session start):
xss-lock -- ~/bin/i3lock-retry -enfi ~/Pictures/lock.png
With xss-lock
running, I set my machine to lock automatically after 600
seconds (10 minutes) of inactivity with:
xset s 600
And locking my machine can be done manually by activating the screensaver with:
xset s activate
Note: i3lock-retry is a simple wrapper-script that calls
i3lock
continuously until it exits successfully (i.e. when the correct
password has been entered). I’ve had some issues with i3lock
crashing in the
past and I just have this wrapper in place because of paranoia over ensuring
my system locks correctly.