what is the most straightforward way to lock the screen AND suspend when closing the lid? I'm using event hooks in /etc/systemd/logind.conf
and successfully suspend upon closing the lid. However I'm lost when it comes to the locking part – am I supposed to enable some screensaver service and how can I trigger two events at once in logind.conf
?
Arch Linux Systemd – Suspend and Lock Screen on Lid Close
arch linuxscreen-locksuspendsystemd
Best Answer
There are a couple of examples in the Arch Wiki.
Basically, it involves creating a service file for your screen locker and ensuring it is hooked to either the
suspend
,hibernate
orsleep
targets.If you use a simple screen locker like slock,
/etc/systemd/system/lock.service
would look like this:Other examples on the wiki have more complex options, including shutting down and bringing up other services, etc.