diff options
Diffstat (limited to 'modules/lock/Pam.qml')
| -rw-r--r-- | modules/lock/Pam.qml | 48 |
1 files changed, 31 insertions, 17 deletions
diff --git a/modules/lock/Pam.qml b/modules/lock/Pam.qml index 44e8671..7863603 100644 --- a/modules/lock/Pam.qml +++ b/modules/lock/Pam.qml @@ -1,8 +1,9 @@ +import Quickshell import Quickshell.Wayland import Quickshell.Services.Pam import QtQuick -PamContext { +Scope { id: root required property WlSessionLock lock @@ -11,11 +12,11 @@ PamContext { property string buffer: "" function handleKey(event: KeyEvent): void { - if (active) + if (passwd.active) return; if (event.key === Qt.Key_Enter || event.key === Qt.Key_Return) { - start(); + passwd.start(); } else if (event.key === Qt.Key_Backspace) { if (event.modifiers & Qt.ControlModifier) { buffer = ""; @@ -28,23 +29,36 @@ PamContext { } } - onResponseRequiredChanged: { - if (!responseRequired) - return; + PamContext { + id: passwd + + onResponseRequiredChanged: { + if (!responseRequired) + return; + + respond(root.buffer); + root.buffer = ""; + } - respond(buffer); - buffer = ""; + onCompleted: res => { + if (res === PamResult.Success) + return root.lock.unlock(); + + if (res === PamResult.Error) + root.state = "error"; + else if (res === PamResult.MaxTries) + root.state = "max"; + else if (res === PamResult.Failed) + root.state = "fail"; + + stateReset.restart(); + } } - onCompleted: res => { - if (res === PamResult.Success) - return lock.unlock(); + Timer { + id: stateReset - if (res === PamResult.Error) - state = "error"; - else if (res === PamResult.MaxTries) - state = "max"; - else if (res === PamResult.Failed) - state = "fail"; + interval: 4000 + onTriggered: root.state = "none" } } |