Home > Cinnamon, English, Linux, Systemd, ThinkPad > Reliable screen lock on sleep in Cinnamon

Reliable screen lock on sleep in Cinnamon

December 2nd, 2014

I’ve been having some problems with Cinnamon’s default lock screen cinnamon-screensaver not reliably being active after resume. Sometimes my screen was still visible for a blink of an eye, sometimes it didn’t even activate at all (often coinciding with hangs of Cinnamon, e.g. caused by FUSE).
In order to fix this I created a simple systemd service following the template in the Arch Wiki.

/etc/systemd/system/screenlock.service:
[Unit]
Description=Lock X session on sleep
Before=sleep.target

[Service]
User=username
Environment=DISPLAY=:0
ExecStart=/usr/bin/cinnamon-screensaver-command -l

[Install]
WantedBy=sleep.target

After enabling the service (systemctl enable screenlock.service) I got a reliable lock screen. It takes my notebook about an extra second to go to sleep now, but I don’t mind that.

Comments are closed.