diff --git a/shell/lock/Lock.qml b/shell/lock/Lock.qml index d31ad0d..e139e16 100644 --- a/shell/lock/Lock.qml +++ b/shell/lock/Lock.qml @@ -40,8 +40,10 @@ Scope { } onExited: { - if (root._sessionPath) + if (root._sessionPath) { _logindMonitor.running = true; + _lockStateCheck.running = true; + } } } @@ -56,7 +58,23 @@ Scope { onRead: data => { if (data.indexOf(".Lock ()") !== -1 && root._enabled) _lock.locked = true; - // Unlock is PAM-driven, ignore logind Unlock signal + else if (data.indexOf(".Unlock ()") !== -1 && _lock.locked) + _lock.locked = false; + } + } + } + + // Check if session is already locked on startup (crash recovery) + Process { + id: _lockStateCheck + running: false + command: ["busctl", "get-property", "--system", "org.freedesktop.login1", root._sessionPath, "org.freedesktop.login1.Session", "LockedHint"] + + stdout: SplitParser { + onRead: data => { + // Output: b true/false + if (data.indexOf("true") !== -1 && root._enabled && !_lock.locked) + _lock.locked = true; } } }