From 56ca1632c5ecd6e1c3124154e689608c359fab1e Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Sun, 10 Aug 2025 19:22:27 +1000 Subject: lock: input field + separate pam --- modules/lock/Pam.qml | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 modules/lock/Pam.qml (limited to 'modules/lock/Pam.qml') diff --git a/modules/lock/Pam.qml b/modules/lock/Pam.qml new file mode 100644 index 0000000..44e8671 --- /dev/null +++ b/modules/lock/Pam.qml @@ -0,0 +1,50 @@ +import Quickshell.Wayland +import Quickshell.Services.Pam +import QtQuick + +PamContext { + id: root + + required property WlSessionLock lock + + property string state: "none" + property string buffer: "" + + function handleKey(event: KeyEvent): void { + if (active) + return; + + if (event.key === Qt.Key_Enter || event.key === Qt.Key_Return) { + start(); + } else if (event.key === Qt.Key_Backspace) { + if (event.modifiers & Qt.ControlModifier) { + buffer = ""; + } else { + buffer = buffer.slice(0, -1); + } + } else if (" abcdefghijklmnopqrstuvwxyz1234567890`~!@#$%^&*()-_=+[{]}\\|;:'\",<.>/?".includes(event.text.toLowerCase())) { + // No illegal characters (you are insane if you use unicode in your password) + buffer += event.text; + } + } + + onResponseRequiredChanged: { + if (!responseRequired) + return; + + respond(buffer); + buffer = ""; + } + + onCompleted: res => { + if (res === PamResult.Success) + return lock.unlock(); + + if (res === PamResult.Error) + state = "error"; + else if (res === PamResult.MaxTries) + state = "max"; + else if (res === PamResult.Failed) + state = "fail"; + } +} -- cgit v1.2.3-freya