I currently use Fedora 22 with a plain Awesome WM session. I can lock the screen with say slock.

There are ways to lock the screen on suspend with the system wide instance of systemd, see this question for instance. The problem with that approach is that it uses a hard-coded DISPLAY variable which is not a nice thing to do. The systemd --user instance cannot depend on system targets, therefore one cannot couple a user task to sleep.target.

On Ubuntu I have been using xss-lock for this task but that is not packaged in Fedora 22 yet. There one runs this tool that will spawn a process when the computer suspends.

Is there some nice way to automatically lock the screen on suspend that works out of the box with Fedora 22?


You can simply use slock for that. Slock supports a second argument. So you may want to pass your suspend command.
For example: slock s2ram or slock systemctl suspend -i You can even specify your own script to run some commands after locking the screen.

| improve this answer | |
  • 1
    This is the wrong way around. I want to be able to close my laptop without locking it manually. Then if I open it, the screen should be locked. That's how it works on KDE (which I am using by now). Manually locking before suspend has the possibility of forgetting to lock. – Martin Ueding Nov 23 '17 at 10:37
  • 1
    Any solution for that @MartinUeding? I'm still interested. – Manoel Vilela Feb 4 '19 at 20:21
  • 1
    @ManoelVilela: I have packaged xss-lock for Fedora at some point, so that should work there as well. But I switched back to KDE and therefore this is no longer a concern for myself. – Martin Ueding Feb 4 '19 at 20:58
  • I made a fix. But only aim people that don't use systemd: gist.github.com/ryukinix/bd0c1ddcbbafdb4149ae70e41b7c822b. But I think that can be systemd-wise portable since this init system ate logind as well. – Manoel Vilela Feb 18 '19 at 14:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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