diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2025-09-05 23:31:35 +0200 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2025-09-05 23:31:35 +0200 |
commit | 14d4d05acc235ab7033316d16530783c90e95faa (patch) | |
tree | 2a6e0953cd5f4e4419274178c8a44a34456ab32c /accounts/gkleen@sif/shell/quickshell/displaymanager.qml | |
parent | 02dbc3d9260fa1137e8ebc99ad439fc555d81fd2 (diff) | |
download | nixos-14d4d05acc235ab7033316d16530783c90e95faa.tar nixos-14d4d05acc235ab7033316d16530783c90e95faa.tar.gz nixos-14d4d05acc235ab7033316d16530783c90e95faa.tar.bz2 nixos-14d4d05acc235ab7033316d16530783c90e95faa.tar.xz nixos-14d4d05acc235ab7033316d16530783c90e95faa.zip |
...quickshell
Diffstat (limited to 'accounts/gkleen@sif/shell/quickshell/displaymanager.qml')
-rw-r--r-- | accounts/gkleen@sif/shell/quickshell/displaymanager.qml | 115 |
1 files changed, 115 insertions, 0 deletions
diff --git a/accounts/gkleen@sif/shell/quickshell/displaymanager.qml b/accounts/gkleen@sif/shell/quickshell/displaymanager.qml new file mode 100644 index 00000000..b452c03d --- /dev/null +++ b/accounts/gkleen@sif/shell/quickshell/displaymanager.qml | |||
@@ -0,0 +1,115 @@ | |||
1 | //@ pragma UseQApplication | ||
2 | |||
3 | import Quickshell | ||
4 | import Quickshell.Wayland | ||
5 | import Quickshell.Io | ||
6 | import Quickshell.Services.Greetd | ||
7 | import QtQml | ||
8 | |||
9 | |||
10 | ShellRoot { | ||
11 | id: displaymanager | ||
12 | |||
13 | settings.watchFiles: false | ||
14 | |||
15 | property string currentText: "" | ||
16 | property string username: @username@ | ||
17 | property list<string> command: @niri_session@ | ||
18 | property list<var> messages: [] | ||
19 | property bool responseRequired: false | ||
20 | property bool responseVisible: false | ||
21 | |||
22 | signal startAuth() | ||
23 | |||
24 | onStartAuth: { | ||
25 | if (Greetd.state !== GreetdState.Inactive) | ||
26 | Greetd.cancelSession(); | ||
27 | displaymanager.messages = []; | ||
28 | Greetd.createSession(displaymanager.username); | ||
29 | } | ||
30 | |||
31 | Connections { | ||
32 | target: Greetd | ||
33 | function onStateChanged() { | ||
34 | console.log("greetd state: ", GreetdState.toString(Greetd.state)); | ||
35 | if (Greetd.state === GreetdState.ReadyToLaunch) | ||
36 | Greetd.launch(displaymanager.command); | ||
37 | } | ||
38 | function onAuthMessage(message: string, error: bool, responseRequired: bool, echoResponse: bool) { | ||
39 | displaymanager.responseVisible = echoResponse; | ||
40 | displaymanager.responseRequired = responseRequired; | ||
41 | displaymanager.messages = Array.from(displaymanager.messages).concat([{ "text": message, "error": error }]); | ||
42 | } | ||
43 | function onAuthFailure(message: string) { | ||
44 | displaymanager.responseRequired = false; | ||
45 | displaymanager.messages = Array.from(displaymanager.messages).concat([{ "text": message, "error": true }]); | ||
46 | } | ||
47 | } | ||
48 | |||
49 | Component.onCompleted: { | ||
50 | if (Greetd.state !== GreetdState.Inactive) | ||
51 | Greetd.cancelSession(); | ||
52 | } | ||
53 | |||
54 | Variants { | ||
55 | model: Quickshell.screens | ||
56 | |||
57 | delegate: Scope { | ||
58 | id: screenScope | ||
59 | |||
60 | required property var modelData | ||
61 | |||
62 | PanelWindow { | ||
63 | color: "black" | ||
64 | |||
65 | screen: screenScope.modelData | ||
66 | |||
67 | WlrLayershell.keyboardFocus: WlrKeyboardFocus.Exclusive | ||
68 | |||
69 | anchors.top: true | ||
70 | anchors.bottom: true | ||
71 | anchors.left: true | ||
72 | anchors.right: true | ||
73 | |||
74 | LockSurface { | ||
75 | id: surfaceContent | ||
76 | |||
77 | screen: screenScope.modelData | ||
78 | |||
79 | onCurrentTextChanged: displaymanager.currentText = currentText | ||
80 | Connections { | ||
81 | target: displaymanager | ||
82 | function onCurrentTextChanged() { surfaceContent.currentText = displaymanager.currentText; } | ||
83 | function onMessagesChanged() { surfaceContent.messages = Array.from(displaymanager.messages); } | ||
84 | function onResponseRequiredChanged() { surfaceContent.responseRequired = displaymanager.responseRequired; } | ||
85 | function onResponseVisibleChanged() { surfaceContent.responseVisible = displaymanager.responseVisible; } | ||
86 | } | ||
87 | |||
88 | onResponse: responseText => Greetd.respond(responseText); | ||
89 | Connections { | ||
90 | target: Greetd | ||
91 | function onStateChanged() { | ||
92 | if (Greetd.state === GreetdState.Authenticating) { | ||
93 | surfaceContent.authRunning = true; | ||
94 | } else { | ||
95 | surfaceContent.authRunning = false; | ||
96 | } | ||
97 | } | ||
98 | } | ||
99 | |||
100 | onAuthRunningChanged: { | ||
101 | if (surfaceContent.authRunning && Greetd.state !== GreetdState.Authenticating) | ||
102 | displaymanager.startAuth(); | ||
103 | } | ||
104 | Component.onCompleted: { | ||
105 | surfaceContent.authRunning = Greetd.state === GreetdState.Authenticating | ||
106 | surfaceContent.messages = Array.from(displaymanager.messages); | ||
107 | surfaceContent.responseVisible = displaymanager.responseVisible; | ||
108 | surfaceContent.responseRequired = displaymanager.responseRequired; | ||
109 | surfaceContent.currentText = displaymanager.currentText; | ||
110 | } | ||
111 | } | ||
112 | } | ||
113 | } | ||
114 | } | ||
115 | } | ||