feat: add lockscreen example
This commit is contained in:
parent
0c568317df
commit
3e1a194d47
6 changed files with 160 additions and 0 deletions
43
lockscreen/AuthContext.qml
Normal file
43
lockscreen/AuthContext.qml
Normal file
|
@ -0,0 +1,43 @@
|
|||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
|
||||
QtObject {
|
||||
property int status: AuthContext.Status.FirstLogin
|
||||
signal unlocked();
|
||||
|
||||
enum Status {
|
||||
FirstLogin,
|
||||
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 {
|
||||
unlocked();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function tryLogin(password: string) {
|
||||
this.password = password
|
||||
status = AuthContext.Status.Authenticating;
|
||||
pamtester.running = true;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue