diff options
Diffstat (limited to 'accounts/gkleen@sif/shell/quickshell/Lockscreen.qml')
-rw-r--r-- | accounts/gkleen@sif/shell/quickshell/Lockscreen.qml | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/accounts/gkleen@sif/shell/quickshell/Lockscreen.qml b/accounts/gkleen@sif/shell/quickshell/Lockscreen.qml new file mode 100644 index 00000000..cc82a275 --- /dev/null +++ b/accounts/gkleen@sif/shell/quickshell/Lockscreen.qml | |||
@@ -0,0 +1,77 @@ | |||
1 | import Quickshell | ||
2 | import Quickshell.Wayland | ||
3 | import Quickshell.Io | ||
4 | import Quickshell.Services.Pam | ||
5 | import QtQml | ||
6 | |||
7 | Scope { | ||
8 | id: lockscreen | ||
9 | |||
10 | property string currentText: "" | ||
11 | |||
12 | PamContext { | ||
13 | id: pam | ||
14 | |||
15 | property list<var> messages: [] | ||
16 | |||
17 | config: "quickshell" | ||
18 | onCompleted: result => { | ||
19 | if (result === PamResult.Success) { | ||
20 | lock.locked = false; | ||
21 | } | ||
22 | } | ||
23 | onPamMessage: { | ||
24 | messages = Array.from(messages).concat([{ "text": pam.message, "error": pam.messageIsError }]) | ||
25 | } | ||
26 | onActiveChanged: { | ||
27 | messages = []; | ||
28 | } | ||
29 | } | ||
30 | |||
31 | IpcHandler { | ||
32 | target: "Lockscreen" | ||
33 | |||
34 | function setLocked(locked: bool): void { lock.locked = locked; } | ||
35 | function getLocked(): bool { return lock.locked; } | ||
36 | } | ||
37 | |||
38 | WlSessionLock { | ||
39 | id: lock | ||
40 | |||
41 | onLockedChanged: { | ||
42 | if (!locked && pam.active) | ||
43 | pam.abort(); | ||
44 | } | ||
45 | |||
46 | WlSessionLockSurface { | ||
47 | id: lockSurface | ||
48 | |||
49 | color: "black" | ||
50 | |||
51 | LockSurface { | ||
52 | id: surfaceContent | ||
53 | |||
54 | onResponse: responseText => pam.respond(responseText) | ||
55 | onAuthRunningChanged: { | ||
56 | if (authRunning) | ||
57 | pam.start(); | ||
58 | } | ||
59 | Connections { | ||
60 | target: pam | ||
61 | function onMessagesChanged() { surfaceContent.messages = pam.messages; } | ||
62 | function onResponseRequiredChanged() { surfaceContent.responseRequired = pam.responseRequired; } | ||
63 | function onActiveChanged() { surfaceContent.authRunning = pam.active; } | ||
64 | } | ||
65 | onCurrentTextChanged: lockscreen.currentText = currentText | ||
66 | Connections { | ||
67 | target: lockscreen | ||
68 | function onCurrentTextChanged() { surfaceContent.currentText = lockscreen.currentText; } | ||
69 | } | ||
70 | Connections { | ||
71 | target: lockSurface | ||
72 | function onScreenChanged() { surfaceContent.screen = lockSurface.screen; } | ||
73 | } | ||
74 | } | ||
75 | } | ||
76 | } | ||
77 | } | ||