lunes, 4 de mayo de 2015

ScreenLock on Jessie's systemd

Something I was used to and which came as standard on wheezy if you installed acpi-support was screen locking when you where suspending, hibernating, ...

This is something that I still haven't found on Jessie and which somebody had point me to solve via /lib/systemd/system-sleep/whatever hacking, but that didn't seem quite right, so I gave it a look again and this time I was able to add some config files at /etc/systemd and then a script which does what acpi-support used to do before

Edit: Michael Biebl has sugested on my google+ post that this is an ugly hack and that one shouldn't use this solution and instead what we should use are solutions with direct support for logind like desktops with built in support or xss-lock, the reasons for this being ugly are pointed at this bug

Edit (2): I've just done the recommended thing for LXDE but it should be similar for any other desktop or window manager lacking logind integration, you just need to apt-get install xss-lock and then add @xss-lock -- xscreensaver-command --lock to .config/lxsession/LXDE/autostart or do it through lxsession-default-apps on the autostart tab. Oh, btw, you don't need acpid or the acpi-support* packages with this setup, so you can remove them safely and avoid weird things.

The main thing here is this little config file: /etc/systemd/system/screenlock.service

The script of course needs execution permissions. I tend to combine this with my power button making the machine hibernate, which was also easier to do before and which is now done at /etc/systemd/logind.conf (doesn't the name already tell you?) where you have to set: HandlePowerKey=hibernate

4 comentarios:

This works in GNOME and I think it works in the other desktop environments. I guess that you are using a custom X session instead?

The modern way to get notifications of suspend in a user session is to talk to logind over D-Bus (http://freedesktop.org/wiki/Software/systemd/logind/). Anything that relies on global hook scripts is going to be a bit of a hack (and insecure on a multi-user system).

I had the same issue after upgrading and used xss-lock. However, I had some trouble with high CPU use by xss-lock after X restart; I had to apply this patch to get it to work properly: https://bitbucket.org/raymonad/xss-lock/commits/2627bce23e9919203f45f4b02c228e4c60a1699b