Lock screen woes

So, I want to set up a lock screen to go off when my computer hibernates when my lid closes

The problem is: I don't use & try to avoid systemd, so no logind. I also don't find any use in a login manager since I'm the only user on my system and tend to just start up my graphics eenvironment with a startx (which defaults to ~/.xsession handling)

My current hibernation works like this:

$ cat /etc/acpi/events/lid_closed 
event=button[ /]lid
action=hibernate-ram

& I'm using gentoo's hibernate-script to handle the peculiarities of screen locking. I could just use /sys/power/state, but having a script to abstract things out is nice and also kind of enables me to do what I want for all of this I think.

In my search, I found xss-lock. which supports DPMS & login manager signaling. DPMS locking is desired, but isn't what I'm looking for right now (that's the easy half of all of this). Unfortunately, as expected, it complains about dbus things:

 $ xss-lock -- i3lock

** (xss-lock:17381): WARNING **: 11:31:30.017: Error taking sleep inhibitor lock: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.login1 was not provided by any .service files

** (xss-lock:17381): WARNING **: 11:31:30.017: Error getting current session: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.login1 was not provided by any .service files

This is expected since I don't have a login manager listening on these services.

Continuing my explorations, I ran into xidlehook --detect-sleep (PR here) that does what I want without any signalling daemon. I even found that my personal overlay already had an ebuild for this, so I've been down this path before.

Unfortunately it does this by detecting timeskips :(

We can do better.


hibernate-scripts ships with an empty /etc/hibernate/scriplets.d and a non-empty lateral /usr/share/hibernate/scriplets.d/. I was pretty much ready to write my own scriplet (based off of only blog post I've found using scriplets.d) but grepping for lock within the directories has let me find /usr/share/hibernate/scriptlets.d/lock.

Looks like what I want is already mostly done!

Looking at the docs in the file, they look like this:

AddConfigHandler LockOptions
AddConfigHelp "LockKDE <boolean>" "Lock all local KDE sessions before suspending."
AddConfigHelp "LockFreedesktop <boolean>" "Lock all local sessions compatible with freedesktop.org screensaver interface before suspending."
AddConfigHelp "LockXScreenSaver <boolean>" "Lock all local X11 sessions with xscreensaver running before suspending."
AddConfigHelp "LockGnomeScreenSaver <boolean>" "Lock all local X11 sessions with gnome-screensaver running before suspending."
AddConfigHelp "LockXLock <boolean>" "Lock active X11 session using xlock."
AddConfigHelp "LockXAutoLock <boolean>" "Lock all local X11 sessions running xautolock."
AddConfigHelp "LockConsoleAs <username>" "Locks the entire system after resuming, requiring you to enter either <username>'s or root's password to unlock it. (Requires vlock)."
AddConfigHelp "LockXtrLock <boolean>" "Lock active X11 session using xtrlock."
AddConfigHelp "LockEnlightenment17 <boolean>" "Lock enlightenment17 session before suspending."

AddOptionHandler LockCmdlineOptions
AddLongOption 'lock-console-as:'
AddOptionHelp '--lock-console-as <username>' 'Uses vlock to lock the entire system after resuming, requirng you to enter the password for the given user to unlock it. This overrides any username given in the configuration file. (Requires vlock)'

Which is still kinda shitty that they support a bunch of individual programs but not what I'm running (which is currently xss-lock with i3lock. or potentially xidlehook).

I've ended up with [a patch](insert link here) to hook hibernate-scripts into any dpms screensaver watchers, making at least the xautolock-specific code redundant as well. & now hibernate-scripts is a bit more future-proof (although they haven't had a commit for eight years, so...).

Everything seems to be working without a hitch, and I even have the upside of no lock screen on hibernate-to-disk (since I've put my new LockXsetDpms true in /etc/hibernate/ram.conf & not disk.conf), letting luks take that job.

What is completion with this project? Maybe taking over maintainership of hibernate-scripts? The patch is done, but there could be more & no one else is taking up the mantle.