3

I've defined the following service to start a screen locker before suspending:

$ cat /etc/systemd/system/screenlock.service
[Unit]
Description=Lock X session using slock
Before=sleep.target

[Service]
User=my_user
Environment=DISPLAY=:0
ExecStart=/usr/bin/xautolock -locknow

[Install]
WantedBy=sleep.target

It is loaded when booting:

$ systemctl status screenlock.service 
● screenlock.service - Lock X session using slock
   Loaded: loaded (/etc/systemd/system/screenlock.service; enabled)
   Active: inactive (dead)

and it is run at some point between triggering suspend to RAM and resuming work:

$ systemctl status screenlock.service 
● screenlock.service - Lock X session using slock
   Loaded: loaded (/etc/systemd/system/screenlock.service; enabled)
   Active: inactive (dead)

Sep 17 08:22:22 machine systemd[1]: Starting Lock X session using slock...
Sep 17 08:22:22 machine systemd[1]: Started Lock X session using slock.

But if it's run before suspending, why do I see a flicker of the desktop before the screen locker turns on when resuming? Is Before or sleep.target not defined as one would expect? Is xautolock or slock faulty?

(I've verified that there's no other service interfering by disabling this one, suspending, resuming, and getting no screen locker.)

  • FWIW, I just start slock from the screenlock service (removes another process) and I never see a flicker... xautolock just handles locking on timeouts. – jasonwryan Sep 17 '14 at 8:16

Your Answer

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

Browse other questions tagged or ask your own question.