From a7805af421eb2783348212b15db83a46b801a524 Mon Sep 17 00:00:00 2001 From: end-4 <97237370+end-4@users.noreply.github.com> Date: Mon, 21 Jul 2025 10:45:33 +0700 Subject: [PATCH] lock: add password box content timeout --- .../ii/modules/lock/LockContext.qml | 94 ++++++++++--------- 1 file changed, 51 insertions(+), 43 deletions(-) diff --git a/.config/quickshell/ii/modules/lock/LockContext.qml b/.config/quickshell/ii/modules/lock/LockContext.qml index c1e8e0bc2..ede61eed8 100644 --- a/.config/quickshell/ii/modules/lock/LockContext.qml +++ b/.config/quickshell/ii/modules/lock/LockContext.qml @@ -4,56 +4,64 @@ import Quickshell import Quickshell.Services.Pam Scope { - id: root - signal shouldReFocus() - signal unlocked() - signal failed() + id: root + signal shouldReFocus() + signal unlocked() + signal failed() - // These properties are in the context and not individual lock surfaces - // so all surfaces can share the same state. - property string currentText: "" - property bool unlockInProgress: false - property bool showFailure: false + // These properties are in the context and not individual lock surfaces + // so all surfaces can share the same state. + property string currentText: "" + property bool unlockInProgress: false + property bool showFailure: false - // Clear the failure text once the user starts typing. - onCurrentTextChanged: { - showFailure = false; - GlobalStates.screenLockContainsCharacters = currentText.length > 0; - } + Timer { + id: passwordClearTimer + interval: 10000 + onTriggered: { + root.currentText = ""; + } + } - function tryUnlock() { - if (currentText === "") return; + onCurrentTextChanged: { + showFailure = false; // Clear the failure text once the user starts typing. + GlobalStates.screenLockContainsCharacters = currentText.length > 0; + passwordClearTimer.restart(); + } - root.unlockInProgress = true; - pam.start(); - } + function tryUnlock() { + if (currentText === "") return; - PamContext { - id: pam + root.unlockInProgress = true; + pam.start(); + } - // Its best to have a custom pam config for quickshell, as the system one - // might not be what your interface expects, and break in some way. - // This particular example only supports passwords. - configDirectory: "pam" - config: "password.conf" + PamContext { + id: pam - // pam_unix will ask for a response for the password prompt - onPamMessage: { - if (this.responseRequired) { - this.respond(root.currentText); - } - } + // Its best to have a custom pam config for quickshell, as the system one + // might not be what your interface expects, and break in some way. + // This particular example only supports passwords. + configDirectory: "pam" + config: "password.conf" - // pam_unix won't send any important messages so all we need is the completion status. - onCompleted: result => { - if (result == PamResult.Success) { - root.unlocked(); - } else { - root.showFailure = true; - } + // pam_unix will ask for a response for the password prompt + onPamMessage: { + if (this.responseRequired) { + this.respond(root.currentText); + } + } - root.currentText = ""; - root.unlockInProgress = false; - } - } + // pam_unix won't send any important messages so all we need is the completion status. + onCompleted: result => { + if (result == PamResult.Success) { + root.unlocked(); + } else { + root.showFailure = true; + } + + root.currentText = ""; + root.unlockInProgress = false; + } + } }