diff options
| author | Leander Scherer <leander@schererleander.de> | 2026-05-18 21:48:24 +0200 |
|---|---|---|
| committer | Leander Scherer <leander@schererleander.de> | 2026-05-28 22:42:07 +0200 |
| commit | 9a7cf1242d296dbdb9c03df48ab09054960295aa (patch) | |
| tree | f1a2d5c77ef6bdb049c995afcc4c663c1ffd1373 /modules/system/quickshell/LockContext.qml | |
| parent | 3ef8b4973bcae26445f99467d50ad75730d204b5 (diff) | |
feat(quickshell): basic bar, tray, notification
Diffstat (limited to 'modules/system/quickshell/LockContext.qml')
| -rw-r--r-- | modules/system/quickshell/LockContext.qml | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/modules/system/quickshell/LockContext.qml b/modules/system/quickshell/LockContext.qml new file mode 100644 index 0000000..05fd1de --- /dev/null +++ b/modules/system/quickshell/LockContext.qml @@ -0,0 +1,58 @@ +import QtQuick +import Quickshell +import Quickshell.Services.Pam + +Scope { + id: root + signal unlocked() + signal failed() + + property string currentText: "" + property bool unlockInProgress: false + property string pamMessage: "" + property bool pamError: false + + onCurrentTextChanged: { + pamError = false; + pamMessage = ""; + } + + function tryUnlock() { + if (currentText === "" || unlockInProgress) return; + unlockInProgress = true; + pam.start(); + } + + function reset() { + currentText = ""; + pamError = false; + pamMessage = ""; + unlockInProgress = false; + } + + PamContext { + id: pam + configDirectory: "pam" + config: "password.conf" + + onPamMessage: { + root.pamMessage = pam.message; + root.pamError = pam.messageIsError; + if (this.responseRequired) { + this.respond(root.currentText); + } + } + + onCompleted: result => { + if (result == PamResult.Success) { + root.currentText = ""; + root.unlocked(); + } else { + root.currentText = ""; + root.pamError = true; + root.failed(); + } + root.unlockInProgress = false; + } + } +} |
