From 67d25119844c094dd69ee9177755ab275d1aa78e Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sat, 23 May 2026 22:59:31 +0200 Subject: [PATCH] Improve shell lock acquisition before sleep --- shell/plugins/lock/Service.qml | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/shell/plugins/lock/Service.qml b/shell/plugins/lock/Service.qml index 39be1780..c7e43d16 100644 --- a/shell/plugins/lock/Service.qml +++ b/shell/plugins/lock/Service.qml @@ -27,6 +27,8 @@ Item { property int failedAttempts: 0 property string backgroundPath: "" property int backgroundVersion: 0 + property string lastEvent: "init" + property string lastEventAt: "" readonly property bool locked: lockRequested || sessionLock.locked || sessionLock.secure readonly property bool authenticating: authenticatingPassword || fingerprintAuthenticating @@ -39,6 +41,12 @@ Item { if (!fingerprintCheckProc.running) fingerprintCheckProc.running = true } + function logEvent(event) { + lastEvent = event + lastEventAt = new Date().toISOString() + console.log("omarchy lock " + lastEventAt + " " + event) + } + function resetAuthenticationState() { enteredPassword = "" pendingPassword = "" @@ -52,14 +60,22 @@ Item { } function beginLock() { - if (!passwordPamConfigured) return false + if (!passwordPamConfigured) { + logEvent("lock-denied: missing-pam") + return false + } resetAuthenticationState() - refreshBackground() - refreshFingerprintStatus() lockRequested = true sessionLock.locked = true idleBlankTimer.restart() + logEvent("lock-requested") + + Qt.callLater(function() { + root.refreshBackground() + root.refreshFingerprintStatus() + }) + return true } @@ -70,6 +86,7 @@ Item { resetAuthenticationState() idleBlankTimer.stop() sessionLock.locked = false + logEvent("unlocked") runWake() } @@ -142,10 +159,13 @@ Item { locked: false onSecureStateChanged: { + root.logEvent("secure=" + secure) if (secure) root.startFingerprint() } onLockStateChanged: { + root.logEvent("session-locked=" + locked) + if (!locked && root.lockRequested) { root.lockRequested = false root.resetAuthenticationState() @@ -331,10 +351,14 @@ Item { function status(): string { return JSON.stringify({ locked: root.locked, + requested: root.lockRequested, + sessionLocked: sessionLock.locked, secure: sessionLock.secure, passwordPam: root.passwordPamConfigured, fingerprint: root.fingerprintConfigured, - authenticating: root.authenticating + authenticating: root.authenticating, + lastEvent: root.lastEvent, + lastEventAt: root.lastEventAt }) }