forked from Shinonome/dots-hyprland
lock: add password box content timeout
This commit is contained in:
@@ -4,56 +4,64 @@ import Quickshell
|
|||||||
import Quickshell.Services.Pam
|
import Quickshell.Services.Pam
|
||||||
|
|
||||||
Scope {
|
Scope {
|
||||||
id: root
|
id: root
|
||||||
signal shouldReFocus()
|
signal shouldReFocus()
|
||||||
signal unlocked()
|
signal unlocked()
|
||||||
signal failed()
|
signal failed()
|
||||||
|
|
||||||
// These properties are in the context and not individual lock surfaces
|
// These properties are in the context and not individual lock surfaces
|
||||||
// so all surfaces can share the same state.
|
// so all surfaces can share the same state.
|
||||||
property string currentText: ""
|
property string currentText: ""
|
||||||
property bool unlockInProgress: false
|
property bool unlockInProgress: false
|
||||||
property bool showFailure: false
|
property bool showFailure: false
|
||||||
|
|
||||||
// Clear the failure text once the user starts typing.
|
Timer {
|
||||||
onCurrentTextChanged: {
|
id: passwordClearTimer
|
||||||
showFailure = false;
|
interval: 10000
|
||||||
GlobalStates.screenLockContainsCharacters = currentText.length > 0;
|
onTriggered: {
|
||||||
}
|
root.currentText = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function tryUnlock() {
|
onCurrentTextChanged: {
|
||||||
if (currentText === "") return;
|
showFailure = false; // Clear the failure text once the user starts typing.
|
||||||
|
GlobalStates.screenLockContainsCharacters = currentText.length > 0;
|
||||||
|
passwordClearTimer.restart();
|
||||||
|
}
|
||||||
|
|
||||||
root.unlockInProgress = true;
|
function tryUnlock() {
|
||||||
pam.start();
|
if (currentText === "") return;
|
||||||
}
|
|
||||||
|
|
||||||
PamContext {
|
root.unlockInProgress = true;
|
||||||
id: pam
|
pam.start();
|
||||||
|
}
|
||||||
|
|
||||||
// Its best to have a custom pam config for quickshell, as the system one
|
PamContext {
|
||||||
// might not be what your interface expects, and break in some way.
|
id: pam
|
||||||
// This particular example only supports passwords.
|
|
||||||
configDirectory: "pam"
|
|
||||||
config: "password.conf"
|
|
||||||
|
|
||||||
// pam_unix will ask for a response for the password prompt
|
// Its best to have a custom pam config for quickshell, as the system one
|
||||||
onPamMessage: {
|
// might not be what your interface expects, and break in some way.
|
||||||
if (this.responseRequired) {
|
// This particular example only supports passwords.
|
||||||
this.respond(root.currentText);
|
configDirectory: "pam"
|
||||||
}
|
config: "password.conf"
|
||||||
}
|
|
||||||
|
|
||||||
// pam_unix won't send any important messages so all we need is the completion status.
|
// pam_unix will ask for a response for the password prompt
|
||||||
onCompleted: result => {
|
onPamMessage: {
|
||||||
if (result == PamResult.Success) {
|
if (this.responseRequired) {
|
||||||
root.unlocked();
|
this.respond(root.currentText);
|
||||||
} else {
|
}
|
||||||
root.showFailure = true;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
root.currentText = "";
|
// pam_unix won't send any important messages so all we need is the completion status.
|
||||||
root.unlockInProgress = false;
|
onCompleted: result => {
|
||||||
}
|
if (result == PamResult.Success) {
|
||||||
}
|
root.unlocked();
|
||||||
|
} else {
|
||||||
|
root.showFailure = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
root.currentText = "";
|
||||||
|
root.unlockInProgress = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user