nixnew/modules/hyprland/lockscreen/AuthContext.qml

44 lines
762 B
QML
Raw Normal View History

2024-03-08 10:30:44 +00:00
import QtQuick
import Quickshell
import Quickshell.Io
QtObject {
property int status: AuthContext.Status.FirstEntry
signal success();
enum Status {
FirstEntry,
Authenticating,
LoginFailed
}
property string password
property var pamtester: Process {
property bool failed: true
command: ["pamtester", "login", Quickshell.env("USER"), "authenticate"]
onStarted: this.write(`${password}\n`)
stdout: SplitParser {
// fails go to stderr
onRead: pamtester.failed = false
}
onExited: {
if (failed) {
status = AuthContext.Status.LoginFailed
} else {
success();
}
}
}
function tryLogin(password: string) {
this.password = password
status = AuthContext.Status.Authenticating;
pamtester.running = true;
}
}