Improve shell lock acquisition before sleep
This commit is contained in:
@@ -27,6 +27,8 @@ Item {
|
|||||||
property int failedAttempts: 0
|
property int failedAttempts: 0
|
||||||
property string backgroundPath: ""
|
property string backgroundPath: ""
|
||||||
property int backgroundVersion: 0
|
property int backgroundVersion: 0
|
||||||
|
property string lastEvent: "init"
|
||||||
|
property string lastEventAt: ""
|
||||||
|
|
||||||
readonly property bool locked: lockRequested || sessionLock.locked || sessionLock.secure
|
readonly property bool locked: lockRequested || sessionLock.locked || sessionLock.secure
|
||||||
readonly property bool authenticating: authenticatingPassword || fingerprintAuthenticating
|
readonly property bool authenticating: authenticatingPassword || fingerprintAuthenticating
|
||||||
@@ -39,6 +41,12 @@ Item {
|
|||||||
if (!fingerprintCheckProc.running) fingerprintCheckProc.running = true
|
if (!fingerprintCheckProc.running) fingerprintCheckProc.running = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function logEvent(event) {
|
||||||
|
lastEvent = event
|
||||||
|
lastEventAt = new Date().toISOString()
|
||||||
|
console.log("omarchy lock " + lastEventAt + " " + event)
|
||||||
|
}
|
||||||
|
|
||||||
function resetAuthenticationState() {
|
function resetAuthenticationState() {
|
||||||
enteredPassword = ""
|
enteredPassword = ""
|
||||||
pendingPassword = ""
|
pendingPassword = ""
|
||||||
@@ -52,14 +60,22 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function beginLock() {
|
function beginLock() {
|
||||||
if (!passwordPamConfigured) return false
|
if (!passwordPamConfigured) {
|
||||||
|
logEvent("lock-denied: missing-pam")
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
resetAuthenticationState()
|
resetAuthenticationState()
|
||||||
refreshBackground()
|
|
||||||
refreshFingerprintStatus()
|
|
||||||
lockRequested = true
|
lockRequested = true
|
||||||
sessionLock.locked = true
|
sessionLock.locked = true
|
||||||
idleBlankTimer.restart()
|
idleBlankTimer.restart()
|
||||||
|
logEvent("lock-requested")
|
||||||
|
|
||||||
|
Qt.callLater(function() {
|
||||||
|
root.refreshBackground()
|
||||||
|
root.refreshFingerprintStatus()
|
||||||
|
})
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,6 +86,7 @@ Item {
|
|||||||
resetAuthenticationState()
|
resetAuthenticationState()
|
||||||
idleBlankTimer.stop()
|
idleBlankTimer.stop()
|
||||||
sessionLock.locked = false
|
sessionLock.locked = false
|
||||||
|
logEvent("unlocked")
|
||||||
runWake()
|
runWake()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,10 +159,13 @@ Item {
|
|||||||
locked: false
|
locked: false
|
||||||
|
|
||||||
onSecureStateChanged: {
|
onSecureStateChanged: {
|
||||||
|
root.logEvent("secure=" + secure)
|
||||||
if (secure) root.startFingerprint()
|
if (secure) root.startFingerprint()
|
||||||
}
|
}
|
||||||
|
|
||||||
onLockStateChanged: {
|
onLockStateChanged: {
|
||||||
|
root.logEvent("session-locked=" + locked)
|
||||||
|
|
||||||
if (!locked && root.lockRequested) {
|
if (!locked && root.lockRequested) {
|
||||||
root.lockRequested = false
|
root.lockRequested = false
|
||||||
root.resetAuthenticationState()
|
root.resetAuthenticationState()
|
||||||
@@ -331,10 +351,14 @@ Item {
|
|||||||
function status(): string {
|
function status(): string {
|
||||||
return JSON.stringify({
|
return JSON.stringify({
|
||||||
locked: root.locked,
|
locked: root.locked,
|
||||||
|
requested: root.lockRequested,
|
||||||
|
sessionLocked: sessionLock.locked,
|
||||||
secure: sessionLock.secure,
|
secure: sessionLock.secure,
|
||||||
passwordPam: root.passwordPamConfigured,
|
passwordPam: root.passwordPamConfigured,
|
||||||
fingerprint: root.fingerprintConfigured,
|
fingerprint: root.fingerprintConfigured,
|
||||||
authenticating: root.authenticating
|
authenticating: root.authenticating,
|
||||||
|
lastEvent: root.lastEvent,
|
||||||
|
lastEventAt: root.lastEventAt
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user