greeter: init greeter

This commit is contained in:
kossLAN 2025-06-20 12:16:19 -04:00
parent be06bf0f86
commit fc9ced0bbe
Signed by: kossLAN
SSH key fingerprint: SHA256:bdV0x+wdQHGJ6LgmstH3KV8OpWY+OOFmJcPcB0wQPV8
6 changed files with 126 additions and 37 deletions

View file

@ -1,3 +1,5 @@
pragma ComponentBehavior: Bound
import QtQuick
import Quickshell
import Quickshell.Services.Pam
@ -5,21 +7,14 @@ import Quickshell.Services.Pam
Scope {
id: root
property string currentText: ""
property bool unlockInProgress: false
property bool showFailure: false
signal unlocked
signal failed
property LockState state: LockState {
onTryUnlock: {
if (this.currentText === "")
return;
// Clear the failure text once the user starts typing.
onCurrentTextChanged: showFailure = false
function tryUnlock() {
if (currentText === "")
return;
root.unlockInProgress = true;
pam.start();
this.unlockInProgress = true;
pam.start();
}
}
PamContext {
@ -34,20 +29,20 @@ Scope {
// pam_unix will ask for a response for the password prompt
onPamMessage: {
if (this.responseRequired) {
this.respond(root.currentText);
this.respond(root.state.currentText);
}
}
// pam_unix won't send any important messages so all we need is the completion status.
onCompleted: result => {
if (result == PamResult.Success) {
root.unlocked();
root.currentText = "";
root.state.unlocked();
root.state.currentText = "";
} else {
root.showFailure = true;
root.state.showFailure = true;
}
root.unlockInProgress = false;
root.state.unlockInProgress = false;
}
}
}