Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 12 down vote accepted

There are a couple of examples on the Arch Wiki systemd page.

Basically, it involves creating a service file for your screen locker and ensuring it is hooked to either the suspend, hibernate or sleep targets.

If you use a simple screen locker like slock, your file would look like this:

Description=Lock the screen on resume from suspend



Other examples on the wiki have more complex options, including shutting down and bringing up other services, etc.

share|improve this answer
Thanks, I saw that example but did not realize the ExecStart=/usr/bin/slock bit refers to locking at first glimpse. – pldimitrov Jul 5 '13 at 1:24
If I suspend and come back, my X display manager has a screen lock, that's great. But what about my ttys? What if I'm logged in, and I suspended and I forgot to exit from my ttys, people could switch to there and continue their operations. – CMCDragonkai Jan 27 at 5:25
@CMCDragonkai you want physlock then... – jasonwryan Jan 27 at 5:31
That looks great, how could one use physlock while disabling KDE's lock screen? I wouldn't want to have to unlock twice, through physlock then KDE's lock screen. – CMCDragonkai Jan 27 at 6:02
@CMCDragonkai no idea: I avoid DEs for precisely that reason... – jasonwryan Jan 27 at 6:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.