Hi folks,

I got annoyed by this bug yet again, so decided to try and fix it and came
up with what I think is a minimal yet robust solution, certainly better
than the various hacks floating around on the Internet today:

https://github.com/mato/xscreensaver-systemd

The above repository contains a single utility which, when run from
~/.xsession or equivalent, will:

1. Lock the screen *before* the system goes to sleep (using
   xscreensaver-command -lock).

2. Ensure the XScreenSaver password dialog is shown *after* the system
   is resumed (using xset to force the screen to power on followed by
   xscreensaver-command -deactivate).

This is implemented using the recommended way to do these things nowadays,
namely inhibitor locks[1]. sd-bus[2] is used for DBUS communication, so the
only dependency is libsystemd (which you already have if you want this).

I originally tried doing this using shell scripts, but it turns out that
DBUS is not scriptable in any sane fashion, then hunted around for a sane
DBUS API and found sd-bus which is actually usable.

Dear Maintainer, if you'd like to ship this as an additional contribution
to the Debian packaging of xscreensaver, feel free.

Jamie, if you're still reading here, if you have a "contrib/" or similar
place in the XScreenSaver distribution, you're likewise welcome to ship
this there.

In either case, let me know if you test/use this -- this code is only
lightly tested so far, and it's possible it leaks sd_bus_messages on
suspend/resume.

Cheers,

Martin

[1] https://www.freedesktop.org/wiki/Software/systemd/inhibit/
[2] http://0pointer.net/blog/the-new-sd-bus-api-of-systemd.html

Reply via email to