Repository navigation
Conversation
`loginctl lock-session` emits Session.Lock on the session object, and a suspend started outside the shell (systemctl suspend, a logind lid or idle action) emits PrepareForSleep. The shell listened to neither, so lock-session did nothing and lock-on-suspend only applied when the shell itself suspended. Follow both for the shell's own session, with logind as the sender. Lock goes through PowerActions.lock_screen(). Before sleep a "sleep" delay inhibitor is released once the lock screen is up (at most 3 s), or at once when lock-on-suspend is off or the session is already locked. Repeated requests are no-ops; Unlock is ignored. Assisted-by: Claude Code:claude-opus-5-5 AI-Scope: Wrote the logind Lock/PrepareForSleep listener, its delay-inhibitor handling and the GTestDBus unit test against a fake logind, from a report that loginctl lock-session was ignored; reviewed and tested on hardware by the author.
Contributor
Author
|
@mirkobrombin for review when you have a moment. This gives the existing lock-on-suspend key a consumer for suspends that do not come from the shell. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
loginctl lock-sessionsends Session.Lock to the session, and a suspend started outside the shell (systemctl suspend, a logind lid or idle action) sends PrepareForSleep. The shell handled neither: lock-session did nothing, and lock-on-suspend only worked when the shell itself started the suspend.The shell now follows Lock for its own logind session (sender checked) and locks through
PowerActions.lock_screen(), the same path as the shortcut and the idle lock. It holds a logind "sleep" delay inhibitor; on PrepareForSleep it locks whenlock-on-suspendis on and releases the inhibitor once the lock screen is up (at most 3 s, so a lock screen that never comes up cannot block sleep). With lock-on-suspend off, or when already locked, the inhibitor is released at once. Repeated requests are ignored, and Unlock is ignored so a lock stays until the user authenticates.Before (main, on hardware):
loginctl lock-sessionleft the session unlocked and no lock client started;systemctl suspendslept with the desktop unlocked.After (the same change carried in our desktop build, on an amd64 laptop and an arm64 desktop):
loginctl lock-session: lock screen up in about 225 ms; a second lock-session while locked starts no second client;loginctl unlock-sessionleaves it locked; wrong password stays locked, right password unlocks; a new lock-session after unlock locks again.systemctl suspendwith lock-on-suspend on: locked about 230 ms after PrepareForSleep, sleep.target reached about 0.6 s later.tests/logind_lock_test.vala(meson test logind-lock) runs the listener against a fake logind on a private bus: session resolution (XDG_SESSION_ID, by PID, user display, none), Lock, repeated Lock, Unlock, sleep with lock-on-suspend on/off, already locked, a lock screen that never comes up, and inhibitor re-take after resume. On Debian forky:ninjabuilds,meson test83 of 85 pass includinglogind-lock(34 checks);parental-helperandcrash-handlerfail the same way on main in a container.AI assistance: disclosed