blob: 456baa98d77357d370a157a00ff8b1e3b7f51595 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
import Quickshell
import Quickshell.Wayland
import Quickshell.Io
import Quickshell.Services.Pam
import Quickshell.Services.Mpris
import Custom as Custom
import qs.Services
import QtQml
Scope {
id: lockscreen
property string currentText: ""
PamContext {
id: pam
property list<var> messages: []
config: "quickshell"
onCompleted: result => {
if (result === PamResult.Success) {
lock.locked = false;
}
}
onPamMessage: {
messages = Array.from(messages).concat([{ "text": pam.message, "error": pam.messageIsError }])
}
onActiveChanged: {
messages = [];
}
}
IpcHandler {
target: "Lockscreen"
function setLocked(locked: bool): void { lock.locked = locked; }
function getLocked(): bool { return lock.locked; }
}
Connections {
target: Custom.Systemd
function onSleep(before: bool) {
console.log(`received prepare for sleep ${before}`);
if (before)
lock.locked = true;
}
function onLock() { lock.locked = true; }
function onUnlock() { lock.locked = false; }
}
IdleMonitor {
id: idleMonitor
enabled: !lock.secure
timeout: 600
respectInhibitors: true
onIsIdleChanged: {
if (idleMonitor.isIdle)
lock.locked = true;
}
}
Custom.SystemdInhibitor {
enabled: !lock.secure
what: Custom.SystemdInhibitorParams.Sleep
who: "quickshell"
why: "Lock session"
mode: Custom.SystemdInhibitorParams.Delay
}
Scope {
id: mprisProxy
property list<var> players: Mpris.players.values
}
WlSessionLock {
id: lock
onLockStateChanged: {
if (!locked && pam.active)
pam.abort();
if (locked) {
NiriService.sendCommand({ "Action": { "PowerOffMonitors": {} } });
Custom.KeePassXC.lockAllDatabases();
Array.from(mprisProxy.players).forEach(player => {
if (player.canPause && player.isPlaying)
player.pause();
});
// Custom.Systemd.stopUserUnit("gpg-agent.service", "replace");
GpgAgent.reloadAgent();
}
}
onSecureStateChanged: Custom.Systemd.lockedHint = lock.secure
WlSessionLockSurface {
id: lockSurface
color: "black"
LockSurface {
id: surfaceContent
onResponse: responseText => pam.respond(responseText)
onAuthRunningChanged: {
if (authRunning)
pam.start();
}
Connections {
target: pam
function onMessagesChanged() { surfaceContent.messages = pam.messages; }
function onResponseRequiredChanged() { surfaceContent.responseRequired = pam.responseRequired; }
function onActiveChanged() { surfaceContent.authRunning = pam.active; }
}
onCurrentTextChanged: lockscreen.currentText = currentText
Connections {
target: lockscreen
function onCurrentTextChanged() { surfaceContent.currentText = lockscreen.currentText; }
}
Connections {
target: lockSurface
function onScreenChanged() { surfaceContent.screen = lockSurface.screen; }
}
}
}
}
}
|