blob: b452c03d2f01eaef9c4abc9ef584f948ba04312f (
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
|
//@ pragma UseQApplication
import Quickshell
import Quickshell.Wayland
import Quickshell.Io
import Quickshell.Services.Greetd
import QtQml
ShellRoot {
id: displaymanager
settings.watchFiles: false
property string currentText: ""
property string username: @username@
property list<string> command: @niri_session@
property list<var> messages: []
property bool responseRequired: false
property bool responseVisible: false
signal startAuth()
onStartAuth: {
if (Greetd.state !== GreetdState.Inactive)
Greetd.cancelSession();
displaymanager.messages = [];
Greetd.createSession(displaymanager.username);
}
Connections {
target: Greetd
function onStateChanged() {
console.log("greetd state: ", GreetdState.toString(Greetd.state));
if (Greetd.state === GreetdState.ReadyToLaunch)
Greetd.launch(displaymanager.command);
}
function onAuthMessage(message: string, error: bool, responseRequired: bool, echoResponse: bool) {
displaymanager.responseVisible = echoResponse;
displaymanager.responseRequired = responseRequired;
displaymanager.messages = Array.from(displaymanager.messages).concat([{ "text": message, "error": error }]);
}
function onAuthFailure(message: string) {
displaymanager.responseRequired = false;
displaymanager.messages = Array.from(displaymanager.messages).concat([{ "text": message, "error": true }]);
}
}
Component.onCompleted: {
if (Greetd.state !== GreetdState.Inactive)
Greetd.cancelSession();
}
Variants {
model: Quickshell.screens
delegate: Scope {
id: screenScope
required property var modelData
PanelWindow {
color: "black"
screen: screenScope.modelData
WlrLayershell.keyboardFocus: WlrKeyboardFocus.Exclusive
anchors.top: true
anchors.bottom: true
anchors.left: true
anchors.right: true
LockSurface {
id: surfaceContent
screen: screenScope.modelData
onCurrentTextChanged: displaymanager.currentText = currentText
Connections {
target: displaymanager
function onCurrentTextChanged() { surfaceContent.currentText = displaymanager.currentText; }
function onMessagesChanged() { surfaceContent.messages = Array.from(displaymanager.messages); }
function onResponseRequiredChanged() { surfaceContent.responseRequired = displaymanager.responseRequired; }
function onResponseVisibleChanged() { surfaceContent.responseVisible = displaymanager.responseVisible; }
}
onResponse: responseText => Greetd.respond(responseText);
Connections {
target: Greetd
function onStateChanged() {
if (Greetd.state === GreetdState.Authenticating) {
surfaceContent.authRunning = true;
} else {
surfaceContent.authRunning = false;
}
}
}
onAuthRunningChanged: {
if (surfaceContent.authRunning && Greetd.state !== GreetdState.Authenticating)
displaymanager.startAuth();
}
Component.onCompleted: {
surfaceContent.authRunning = Greetd.state === GreetdState.Authenticating
surfaceContent.messages = Array.from(displaymanager.messages);
surfaceContent.responseVisible = displaymanager.responseVisible;
surfaceContent.responseRequired = displaymanager.responseRequired;
surfaceContent.currentText = displaymanager.currentText;
}
}
}
}
}
}
|