summaryrefslogtreecommitdiff
path: root/accounts/gkleen@sif/shell/quickshell/Lockscreen.qml
diff options
context:
space:
mode:
Diffstat (limited to 'accounts/gkleen@sif/shell/quickshell/Lockscreen.qml')
-rw-r--r--accounts/gkleen@sif/shell/quickshell/Lockscreen.qml90
1 files changed, 90 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..8e739359
--- /dev/null
+++ b/accounts/gkleen@sif/shell/quickshell/Lockscreen.qml
@@ -0,0 +1,90 @@
1import Quickshell
2import Quickshell.Wayland
3import Quickshell.Io
4import Quickshell.Services.Pam
5import Quickshell.Services.Mpris
6import Custom as Custom
7import qs.Services
8import QtQml
9
10Scope {
11 id: lockscreen
12
13 property string currentText: ""
14
15 PamContext {
16 id: pam
17
18 property list<var> messages: []
19
20 config: "quickshell"
21 onCompleted: result => {
22 if (result === PamResult.Success) {
23 lock.locked = false;
24 }
25 }
26 onPamMessage: {
27 messages = Array.from(messages).concat([{ "text": pam.message, "error": pam.messageIsError }])
28 }
29 onActiveChanged: {
30 messages = [];
31 }
32 }
33
34 IpcHandler {
35 target: "Lockscreen"
36
37 function setLocked(locked: bool): void { lock.locked = locked; }
38 function getLocked(): bool { return lock.locked; }
39 }
40
41 WlSessionLock {
42 id: lock
43
44 onLockStateChanged: {
45 if (!locked && pam.active)
46 pam.abort();
47
48 if (locked) {
49 Custom.KeePassXC.lockAllDatabases();
50 Array.from(Mpris.players.values).forEach(player => {
51 if (player.canPause && player.isPlaying)
52 player.pause();
53 });
54 // Custom.Systemd.stopUserUnit("gpg-agent.service", "replace");
55 GpgAgent.reloadAgent();
56 }
57 }
58
59 WlSessionLockSurface {
60 id: lockSurface
61
62 color: "black"
63
64 LockSurface {
65 id: surfaceContent
66
67 onResponse: responseText => pam.respond(responseText)
68 onAuthRunningChanged: {
69 if (authRunning)
70 pam.start();
71 }
72 Connections {
73 target: pam
74 function onMessagesChanged() { surfaceContent.messages = pam.messages; }
75 function onResponseRequiredChanged() { surfaceContent.responseRequired = pam.responseRequired; }
76 function onActiveChanged() { surfaceContent.authRunning = pam.active; }
77 }
78 onCurrentTextChanged: lockscreen.currentText = currentText
79 Connections {
80 target: lockscreen
81 function onCurrentTextChanged() { surfaceContent.currentText = lockscreen.currentText; }
82 }
83 Connections {
84 target: lockSurface
85 function onScreenChanged() { surfaceContent.screen = lockSurface.screen; }
86 }
87 }
88 }
89 }
90}