1
0
Fork 0

lockscreen: replace lockscreen example

The new one uses the pam module and looks much nicer.
This commit is contained in:
outfoxxed 2024-06-18 17:14:51 -07:00
parent c30a4faf18
commit a64b477dea
Signed by: outfoxxed
GPG key ID: 4C88A185FB89301E
9 changed files with 190 additions and 126 deletions

View file

@ -0,0 +1,54 @@
import QtQuick
import Quickshell
import Quickshell.Services.Pam
Scope {
id: root
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
// Clear the failure text once the user starts typing.
onCurrentTextChanged: showFailure = false;
function tryUnlock() {
if (currentText === "") return;
root.unlockInProgress = true;
pam.start();
}
PamContext {
id: pam
// 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 will ask for a response for the password prompt
onPamMessage: {
if (this.responseRequired) {
this.respond(root.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();
} else {
root.currentText = "";
root.showFailure = true;
}
root.unlockInProgress = false;
}
}
}