diff options
Diffstat (limited to 'accounts/gkleen@sif/shell/quickshell')
17 files changed, 1959 insertions, 315 deletions
diff --git a/accounts/gkleen@sif/shell/quickshell/ActiveWindowDisplay.qml b/accounts/gkleen@sif/shell/quickshell/ActiveWindowDisplay.qml new file mode 100644 index 00000000..57ade488 --- /dev/null +++ b/accounts/gkleen@sif/shell/quickshell/ActiveWindowDisplay.qml | |||
@@ -0,0 +1,94 @@ | |||
1 | import QtQuick | ||
2 | import qs.Services | ||
3 | import Quickshell | ||
4 | import Quickshell.Widgets | ||
5 | |||
6 | Item { | ||
7 | id: activeWindowDisplay | ||
8 | |||
9 | required property int maxWidth | ||
10 | required property var screen | ||
11 | |||
12 | property var activeWindow: { | ||
13 | let currWindowId = Array.from(NiriService.workspaces).find(ws => { | ||
14 | return ws.output === screen.name && ws.is_active; | ||
15 | })?.active_window_id; | ||
16 | |||
17 | return currWindowId ? Array.from(NiriService.windows).find(win => win.id == currWindowId) : null; | ||
18 | } | ||
19 | property var windowEntry: activeWindow ? DesktopEntries.heuristicLookup(activeWindow.app_id) : null | ||
20 | |||
21 | anchors.verticalCenter: parent.verticalCenter | ||
22 | width: activeWindowDisplayContent.width | ||
23 | height: parent.height | ||
24 | |||
25 | Row { | ||
26 | id: activeWindowDisplayContent | ||
27 | |||
28 | width: childrenRect.width | ||
29 | height: parent.height | ||
30 | anchors.verticalCenter: parent.verticalCenter | ||
31 | spacing: 8 | ||
32 | |||
33 | IconImage { | ||
34 | id: activeWindowIcon | ||
35 | |||
36 | height: 14 | ||
37 | width: 14 | ||
38 | |||
39 | anchors.verticalCenter: parent.verticalCenter | ||
40 | |||
41 | source: { | ||
42 | let icon = activeWindowDisplay.windowEntry?.icon | ||
43 | if (typeof icon === 'string' || icon instanceof String) { | ||
44 | if (icon.includes("?path=")) { | ||
45 | const split = icon.split("?path=") | ||
46 | if (split.length !== 2) | ||
47 | return icon | ||
48 | const name = split[0] | ||
49 | const path = split[1] | ||
50 | const fileName = name.substring( | ||
51 | name.lastIndexOf("/") + 1) | ||
52 | return `file://${path}/${fileName}` | ||
53 | } else | ||
54 | icon = Quickshell.iconPath(icon); | ||
55 | return icon | ||
56 | } | ||
57 | return "" | ||
58 | } | ||
59 | asynchronous: true | ||
60 | smooth: true | ||
61 | mipmap: true | ||
62 | } | ||
63 | |||
64 | Text { | ||
65 | id: windowTitle | ||
66 | |||
67 | width: Math.min(implicitWidth, activeWindowDisplay.maxWidth - activeWindowIcon.width - activeWindowDisplayContent.spacing) | ||
68 | |||
69 | property var appAliases: { "Firefox": "Mozilla Firefox", "mpv Media Player": "mpv", "Thunderbird": "Mozilla Thunderbird", "Thunderbird (LMU)": "Mozilla Thunderbird" } | ||
70 | |||
71 | elide: Text.ElideRight | ||
72 | maximumLineCount: 1 | ||
73 | color: "white" | ||
74 | anchors.verticalCenter: parent.verticalCenter | ||
75 | text: { | ||
76 | if (!activeWindowDisplay.activeWindow) | ||
77 | return ""; | ||
78 | |||
79 | var title = activeWindowDisplay.activeWindow.title; | ||
80 | var appName = activeWindowDisplay.windowEntry?.name; | ||
81 | if (appAliases[appName]) | ||
82 | appName = appAliases[appName]; | ||
83 | if (appName && title.endsWith(appName)) { | ||
84 | const oldTitle = title; | ||
85 | title = title.substring(0, title.length - appName.length); | ||
86 | title = title.replace(/\s*(—|-)\s*$/, ""); | ||
87 | if (!title) | ||
88 | title = oldTitle; | ||
89 | } | ||
90 | return title; | ||
91 | } | ||
92 | } | ||
93 | } | ||
94 | } | ||
diff --git a/accounts/gkleen@sif/shell/quickshell/Bar.qml b/accounts/gkleen@sif/shell/quickshell/Bar.qml index 09554a39..3652af54 100644 --- a/accounts/gkleen@sif/shell/quickshell/Bar.qml +++ b/accounts/gkleen@sif/shell/quickshell/Bar.qml | |||
@@ -1,16 +1,11 @@ | |||
1 | import Quickshell | 1 | import Quickshell |
2 | import Quickshell.Io | ||
3 | import Quickshell.Services.SystemTray | ||
4 | import Quickshell.Widgets | ||
5 | import Custom as Custom | ||
6 | import QtQuick | 2 | import QtQuick |
7 | import qs.Services | ||
8 | 3 | ||
9 | 4 | ||
10 | PanelWindow { | 5 | PanelWindow { |
11 | id: bar | 6 | id: bar |
12 | 7 | ||
13 | property var modelData | 8 | required property var screen |
14 | 9 | ||
15 | anchors { | 10 | anchors { |
16 | top: true | 11 | top: true |
@@ -22,12 +17,11 @@ PanelWindow { | |||
22 | right: 26 + 8 | 17 | right: 26 + 8 |
23 | } | 18 | } |
24 | 19 | ||
25 | screen: modelData | ||
26 | implicitHeight: 21 | 20 | implicitHeight: 21 |
27 | color: "transparent" | 21 | color: "transparent" |
28 | 22 | ||
29 | Rectangle { | 23 | Rectangle { |
30 | color: Qt.rgba(0, 0, 0, 0.66) | 24 | color: Qt.rgba(0, 0, 0, 0.75) |
31 | anchors.fill: parent | 25 | anchors.fill: parent |
32 | // bottomLeftRadius: 8 | 26 | // bottomLeftRadius: 8 |
33 | // bottomRightRadius: 8 | 27 | // bottomRightRadius: 8 |
@@ -43,74 +37,7 @@ PanelWindow { | |||
43 | anchors.verticalCenter: parent.verticalCenter | 37 | anchors.verticalCenter: parent.verticalCenter |
44 | spacing: 8 | 38 | spacing: 8 |
45 | 39 | ||
46 | Row { | 40 | WorkspaceSwitcher {} |
47 | id: workspaces | ||
48 | |||
49 | property var ignoreWorkspaces: @ignore_workspaces@ | ||
50 | |||
51 | height: parent.height | ||
52 | anchors.verticalCenter: parent.verticalCenter | ||
53 | spacing: 0 | ||
54 | |||
55 | Repeater { | ||
56 | model: { | ||
57 | let currWorkspaces = NiriService.workspaces; | ||
58 | const ignoreWorkspaces = Array.from(workspaces.ignoreWorkspaces); | ||
59 | currWorkspaces = currWorkspaces.filter(ws => ws.is_active || ignoreWorkspaces.every(iws => iws !== ws.name)); | ||
60 | currWorkspaces.sort((a, b) => { | ||
61 | if (NiriService.outputs?.[a.output]?.logical?.x !== NiriService.outputs?.[b.output]?.logical?.x) | ||
62 | return NiriService.outputs?.[a.output]?.logical?.x - NiriService.outputs?.[b.output]?.logical?.x | ||
63 | if (NiriService.outputs?.[a.output]?.logical?.y !== NiriService.outputs?.[b.output]?.logical?.y) | ||
64 | return NiriService.outputs?.[a.output]?.logical?.y - NiriService.outputs?.[b.output]?.logical?.y | ||
65 | return a.idx - b.idx; | ||
66 | }); | ||
67 | return currWorkspaces; | ||
68 | } | ||
69 | |||
70 | Rectangle { | ||
71 | property var workspaceData: modelData | ||
72 | |||
73 | width: wsLabel.contentWidth + 8 | ||
74 | color: { | ||
75 | if (mouseArea.containsMouse) { | ||
76 | return "#33808080"; | ||
77 | } | ||
78 | return "transparent"; | ||
79 | } | ||
80 | height: parent.height | ||
81 | anchors.verticalCenter: parent.verticalCenter | ||
82 | |||
83 | MouseArea { | ||
84 | id: mouseArea | ||
85 | |||
86 | anchors.fill: parent | ||
87 | hoverEnabled: true | ||
88 | cursorShape: Qt.PointingHandCursor | ||
89 | enabled: true | ||
90 | onClicked: { | ||
91 | NiriService.sendCommand({ "Action": { "FocusWorkspace": { "reference": { "Id": workspaceData.id } } } }, _ => {}) | ||
92 | } | ||
93 | } | ||
94 | |||
95 | Text { | ||
96 | id: wsLabel | ||
97 | |||
98 | font.pointSize: 10 | ||
99 | font.family: "Fira Sans" | ||
100 | color: { | ||
101 | if (workspaceData.active_window_id === null) | ||
102 | return "#555"; | ||
103 | if (workspaceData.is_active) | ||
104 | return "#23fd00"; | ||
105 | return "white"; | ||
106 | } | ||
107 | anchors.centerIn: parent | ||
108 | |||
109 | text: workspaceData.name ? workspaceData.name : workspaceData.idx | ||
110 | } | ||
111 | } | ||
112 | } | ||
113 | } | ||
114 | } | 41 | } |
115 | 42 | ||
116 | Row { | 43 | Row { |
@@ -121,91 +48,9 @@ PanelWindow { | |||
121 | anchors.centerIn: parent | 48 | anchors.centerIn: parent |
122 | spacing: 5 | 49 | spacing: 5 |
123 | 50 | ||
124 | Item { | 51 | ActiveWindowDisplay { |
125 | id: activeWindowDisplay | 52 | screen: bar.screen |
126 | 53 | maxWidth: bar.width - 2*Math.max(left.width, right.width) - 2*8 | |
127 | property var activeWindow: { | ||
128 | let currWindowId = Array.from(NiriService.workspaces).find(ws => { | ||
129 | return ws.output === bar.screen.name && ws.is_active; | ||
130 | })?.active_window_id; | ||
131 | |||
132 | return currWindowId ? Array.from(NiriService.windows).find(win => win.id == currWindowId) : null; | ||
133 | } | ||
134 | property var windowEntry: activeWindow ? DesktopEntries.heuristicLookup(activeWindow.app_id) : null | ||
135 | |||
136 | anchors.verticalCenter: parent.verticalCenter | ||
137 | width: activeWindowDisplayContent.width | ||
138 | height: parent.height | ||
139 | |||
140 | Row { | ||
141 | id: activeWindowDisplayContent | ||
142 | |||
143 | width: childrenRect.width | ||
144 | height: parent.height | ||
145 | anchors.verticalCenter: parent.verticalCenter | ||
146 | spacing: 8 | ||
147 | |||
148 | IconImage { | ||
149 | id: activeWindowIcon | ||
150 | |||
151 | height: 14 | ||
152 | width: 14 | ||
153 | |||
154 | anchors.verticalCenter: parent.verticalCenter | ||
155 | |||
156 | source: { | ||
157 | let icon = activeWindowDisplay.windowEntry?.icon | ||
158 | if (typeof icon === 'string' || icon instanceof String) { | ||
159 | if (icon.includes("?path=")) { | ||
160 | const split = icon.split("?path=") | ||
161 | if (split.length !== 2) | ||
162 | return icon | ||
163 | const name = split[0] | ||
164 | const path = split[1] | ||
165 | const fileName = name.substring( | ||
166 | name.lastIndexOf("/") + 1) | ||
167 | return `file://${path}/${fileName}` | ||
168 | } else | ||
169 | icon = Quickshell.iconPath(icon); | ||
170 | return icon | ||
171 | } | ||
172 | return "" | ||
173 | } | ||
174 | asynchronous: true | ||
175 | smooth: true | ||
176 | mipmap: true | ||
177 | } | ||
178 | |||
179 | Text { | ||
180 | id: windowTitle | ||
181 | |||
182 | width: Math.min(implicitWidth, bar.width - 2*Math.max(left.width, right.width) - 2*8 - activeWindowIcon.width - activeWindowDisplayContent.spacing) | ||
183 | |||
184 | property var appAliases: { "Firefox": "Mozilla Firefox", "mpv Media Player": "mpv", "Thunderbird": "Mozilla Thunderbird", "Thunderbird (LMU)": "Mozilla Thunderbird" } | ||
185 | |||
186 | elide: Text.ElideRight | ||
187 | maximumLineCount: 1 | ||
188 | color: "white" | ||
189 | anchors.verticalCenter: parent.verticalCenter | ||
190 | text: { | ||
191 | if (!activeWindowDisplay.activeWindow) | ||
192 | return ""; | ||
193 | |||
194 | var title = activeWindowDisplay.activeWindow.title; | ||
195 | var appName = activeWindowDisplay.windowEntry?.name; | ||
196 | if (appAliases[appName]) | ||
197 | appName = appAliases[appName]; | ||
198 | if (appName && title.endsWith(appName)) { | ||
199 | const oldTitle = title; | ||
200 | title = title.substring(0, title.length - appName.length); | ||
201 | title = title.replace(/\s*(—|-)\s*$/, ""); | ||
202 | if (!title) | ||
203 | title = oldTitle; | ||
204 | } | ||
205 | return title; | ||
206 | } | ||
207 | } | ||
208 | } | ||
209 | } | 54 | } |
210 | } | 55 | } |
211 | 56 | ||
@@ -217,160 +62,29 @@ PanelWindow { | |||
217 | anchors.right: parent.right | 62 | anchors.right: parent.right |
218 | anchors.rightMargin: 8 | 63 | anchors.rightMargin: 8 |
219 | anchors.verticalCenter: parent.verticalCenter | 64 | anchors.verticalCenter: parent.verticalCenter |
220 | spacing: 8 | 65 | spacing: 0 |
221 | |||
222 | Rectangle { | ||
223 | id: kbdWidget | ||
224 | 66 | ||
225 | property var keyboardAbbrev: { "English (programmer Dvorak)": "dvp", "English (US)": "us" } | 67 | PipewireWidget {} |
226 | 68 | ||
227 | width: kbdLabel.contentWidth | 69 | Item { |
228 | color: { | ||
229 | /* if (kbdMouseArea.containsMouse) { | ||
230 | return "#33808080"; | ||
231 | } */ | ||
232 | return "transparent"; | ||
233 | } | ||
234 | height: parent.height | 70 | height: parent.height |
235 | anchors.verticalCenter: parent.verticalCenter | 71 | width: 4 |
236 | |||
237 | MouseArea { | ||
238 | id: kbdMouseArea | ||
239 | |||
240 | anchors.fill: parent | ||
241 | hoverEnabled: true | ||
242 | cursorShape: Qt.PointingHandCursor | ||
243 | enabled: true | ||
244 | onClicked: { | ||
245 | NiriService.sendCommand({ "Action": { "SwitchLayout": { "layout": "Next" } } }, _ => {}) | ||
246 | } | ||
247 | } | ||
248 | |||
249 | Text { | ||
250 | id: kbdLabel | ||
251 | |||
252 | font.pointSize: 10 | ||
253 | font.family: "Fira Sans" | ||
254 | color: { | ||
255 | if (NiriService.keyboardLayouts?.current_idx === 0) | ||
256 | return "#555"; | ||
257 | return "white"; | ||
258 | } | ||
259 | anchors.centerIn: parent | ||
260 | |||
261 | text: { | ||
262 | const currentLayout = NiriService.keyboardLayouts?.names?.[NiriService.keyboardLayouts.current_idx]; | ||
263 | return kbdWidget.keyboardAbbrev[currentLayout] ? kbdWidget.keyboardAbbrev[currentLayout] : currentLayout; | ||
264 | } | ||
265 | } | ||
266 | } | 72 | } |
267 | 73 | ||
74 | SystemTray {} | ||
75 | |||
268 | Item { | 76 | Item { |
269 | anchors.verticalCenter: parent.verticalCenter | ||
270 | width: systemTrayRow.childrenRect.width | ||
271 | height: parent.height | 77 | height: parent.height |
272 | clip: true | 78 | width: 4 |
273 | |||
274 | Row { | ||
275 | id: systemTrayRow | ||
276 | anchors.centerIn: parent | ||
277 | width: childrenRect.width | ||
278 | height: parent.height | ||
279 | spacing: 0 | ||
280 | |||
281 | Repeater { | ||
282 | model: SystemTray.items.values | ||
283 | |||
284 | delegate: Item { | ||
285 | property var trayItem: modelData | ||
286 | property string iconSource: { | ||
287 | let icon = trayItem && trayItem.icon | ||
288 | if (typeof icon === 'string' || icon instanceof String) { | ||
289 | if (icon.includes("?path=")) { | ||
290 | const split = icon.split("?path=") | ||
291 | if (split.length !== 2) | ||
292 | return icon | ||
293 | const name = split[0] | ||
294 | const path = split[1] | ||
295 | const fileName = name.substring( | ||
296 | name.lastIndexOf("/") + 1) | ||
297 | return `file://${path}/${fileName}` | ||
298 | } | ||
299 | return icon | ||
300 | } | ||
301 | return "" | ||
302 | } | ||
303 | |||
304 | width: 16 | ||
305 | height: parent.height | ||
306 | anchors.verticalCenter: parent.verticalCenter | ||
307 | |||
308 | IconImage { | ||
309 | anchors.centerIn: parent | ||
310 | width: parent.width | ||
311 | height: parent.width | ||
312 | source: parent.iconSource | ||
313 | asynchronous: true | ||
314 | smooth: true | ||
315 | mipmap: true | ||
316 | } | ||
317 | |||
318 | MouseArea { | ||
319 | id: trayItemArea | ||
320 | |||
321 | anchors.fill: parent | ||
322 | acceptedButtons: Qt.LeftButton | Qt.RightButton | ||
323 | hoverEnabled: true | ||
324 | cursorShape: Qt.PointingHandCursor | ||
325 | onClicked: mouse => { | ||
326 | if (!trayItem) | ||
327 | return | ||
328 | |||
329 | if (mouse.button === Qt.LeftButton | ||
330 | && !trayItem.onlyMenu) { | ||
331 | trayItem.activate() | ||
332 | return | ||
333 | } | ||
334 | |||
335 | if (trayItem.hasMenu) { | ||
336 | var globalPos = mapToGlobal(0, 0) | ||
337 | var currentScreen = screen || Screen | ||
338 | var screenX = currentScreen.x || 0 | ||
339 | var relativeX = globalPos.x - screenX | ||
340 | menuAnchor.menu = trayItem.menu | ||
341 | menuAnchor.anchor.window = bar | ||
342 | menuAnchor.anchor.rect = Qt.rect( | ||
343 | relativeX, | ||
344 | 21, | ||
345 | parent.width, 1) | ||
346 | menuAnchor.open() | ||
347 | } | ||
348 | } | ||
349 | } | ||
350 | } | ||
351 | } | ||
352 | } | ||
353 | QsMenuAnchor { | ||
354 | id: menuAnchor | ||
355 | } | ||
356 | } | 79 | } |
357 | 80 | ||
358 | Text { | 81 | KeyboardLayout {} |
359 | id: clock | ||
360 | color: "white" | ||
361 | 82 | ||
362 | anchors.verticalCenter: parent.verticalCenter | 83 | Item { |
363 | 84 | height: parent.height | |
364 | Custom.Chrono { | 85 | width: 4 |
365 | id: chrono | ||
366 | format: "W{0:%V-%u} {0:%F} {0:%H:%M:%S%Ez}" | ||
367 | } | ||
368 | |||
369 | text: chrono.date | ||
370 | |||
371 | font.pointSize: 10 | ||
372 | font.family: "Fira Sans" | ||
373 | font.features: { "tnum": 1 } | ||
374 | } | 86 | } |
87 | |||
88 | Clock {} | ||
375 | } | 89 | } |
376 | } \ No newline at end of file | 90 | } \ No newline at end of file |
diff --git a/accounts/gkleen@sif/shell/quickshell/Clock.qml b/accounts/gkleen@sif/shell/quickshell/Clock.qml new file mode 100644 index 00000000..4644d5e7 --- /dev/null +++ b/accounts/gkleen@sif/shell/quickshell/Clock.qml | |||
@@ -0,0 +1,284 @@ | |||
1 | import QtQml | ||
2 | import QtQuick | ||
3 | import Quickshell | ||
4 | import Custom as Custom | ||
5 | import QtQuick.Controls | ||
6 | import QtQuick.Layouts | ||
7 | import Quickshell.Widgets | ||
8 | |||
9 | Item { | ||
10 | id: clockItem | ||
11 | |||
12 | property bool calendarPopup: true | ||
13 | |||
14 | width: clock.contentWidth | ||
15 | height: parent.height | ||
16 | anchors.verticalCenter: parent.verticalCenter | ||
17 | |||
18 | WrapperMouseArea { | ||
19 | id: clockMouseArea | ||
20 | |||
21 | anchors.fill: parent | ||
22 | hoverEnabled: true | ||
23 | enabled: clockItem.calendarPopup | ||
24 | |||
25 | Item { | ||
26 | anchors.fill: parent | ||
27 | |||
28 | Text { | ||
29 | id: clock | ||
30 | color: "white" | ||
31 | |||
32 | anchors.verticalCenter: parent.verticalCenter | ||
33 | |||
34 | Custom.Chrono { | ||
35 | id: chrono | ||
36 | |||
37 | onDateChanged: clock.text = format("W{0:%V-%u} {0:%F} {0:%H:%M:%S%Ez}") | ||
38 | } | ||
39 | |||
40 | font.pointSize: 10 | ||
41 | font.family: "Fira Sans" | ||
42 | font.features: { "tnum": 1 } | ||
43 | } | ||
44 | } | ||
45 | } | ||
46 | |||
47 | Loader { | ||
48 | id: tooltipLoader | ||
49 | |||
50 | active: false | ||
51 | |||
52 | Connections { | ||
53 | target: clockMouseArea | ||
54 | function onContainsMouseChanged() { | ||
55 | if (clockMouseArea.containsMouse) | ||
56 | tooltipLoader.active = true; | ||
57 | } | ||
58 | } | ||
59 | |||
60 | sourceComponent: PopupWindow { | ||
61 | id: tooltip | ||
62 | |||
63 | property bool nextVisible: clockMouseArea.containsMouse || tooltipMouseArea.containsMouse | ||
64 | |||
65 | anchor { | ||
66 | item: clockMouseArea | ||
67 | edges: Edges.Bottom | Edges.Left | ||
68 | } | ||
69 | visible: false | ||
70 | |||
71 | onNextVisibleChanged: hangTimer.restart() | ||
72 | |||
73 | Timer { | ||
74 | id: hangTimer | ||
75 | interval: 100 | ||
76 | onTriggered: tooltip.visible = tooltip.nextVisible | ||
77 | } | ||
78 | |||
79 | implicitWidth: clockTooltipContent.width | ||
80 | implicitHeight: clockTooltipContent.height | ||
81 | color: "black" | ||
82 | |||
83 | onVisibleChanged: { | ||
84 | yearCalendar.year = chrono.date.getFullYear(); | ||
85 | yearCalendar.angleRem = 0; | ||
86 | } | ||
87 | |||
88 | WrapperMouseArea { | ||
89 | id: tooltipMouseArea | ||
90 | |||
91 | hoverEnabled: true | ||
92 | enabled: true | ||
93 | |||
94 | onWheel: event => yearCalendar.scrollYear(event) | ||
95 | |||
96 | anchors.fill: parent | ||
97 | |||
98 | WrapperItem { | ||
99 | id: clockTooltipContent | ||
100 | |||
101 | margin: 8 | ||
102 | |||
103 | ColumnLayout { | ||
104 | anchors.centerIn: parent | ||
105 | |||
106 | Text { | ||
107 | id: yearLabel | ||
108 | |||
109 | horizontalAlignment: Text.AlignHCenter | ||
110 | |||
111 | font.pointSize: 14 | ||
112 | font.family: "Fira Sans" | ||
113 | font.features: { "tnum": 1 } | ||
114 | color: "white" | ||
115 | |||
116 | text: yearCalendar.year | ||
117 | |||
118 | Layout.fillWidth: true | ||
119 | Layout.bottomMargin: 8 | ||
120 | } | ||
121 | |||
122 | GridLayout { | ||
123 | property int year: chrono.date.getFullYear() | ||
124 | |||
125 | id: yearCalendar | ||
126 | |||
127 | columns: 3 | ||
128 | columnSpacing: 16 | ||
129 | rowSpacing: 16 | ||
130 | |||
131 | Layout.alignment: Qt.AlignHCenter | ||
132 | Layout.fillWidth: false | ||
133 | |||
134 | property real angleRem: 0 | ||
135 | property real sensitivity: 1 / 120 | ||
136 | |||
137 | function scrollYear(event) { | ||
138 | angleRem += event.angleDelta.y; | ||
139 | const d = Math.round(angleRem * sensitivity); | ||
140 | yearCalendar.year += d; | ||
141 | angleRem -= d / sensitivity; | ||
142 | } | ||
143 | |||
144 | Connections { | ||
145 | target: clockMouseArea | ||
146 | function onWheel(event) { yearCalendar.scrollYear(event); } | ||
147 | } | ||
148 | |||
149 | Repeater { | ||
150 | model: 12 | ||
151 | |||
152 | GridLayout { | ||
153 | columns: 2 | ||
154 | |||
155 | required property int index | ||
156 | property int month: index | ||
157 | |||
158 | id: monthCalendar | ||
159 | |||
160 | Layout.alignment: Qt.AlignTop | Qt.AlignRight | ||
161 | Layout.fillWidth: false | ||
162 | |||
163 | Text { | ||
164 | Layout.column: 1 | ||
165 | Layout.fillWidth: true | ||
166 | |||
167 | horizontalAlignment: Text.AlignHCenter | ||
168 | |||
169 | font.pointSize: 10 | ||
170 | font.family: "Fira Sans" | ||
171 | |||
172 | text: new Date(yearCalendar.year, monthCalendar.month, 1).toLocaleString(Qt.locale("en_DK"), "MMMM") | ||
173 | |||
174 | color: "#ffead3" | ||
175 | } | ||
176 | |||
177 | DayOfWeekRow { | ||
178 | locale: grid.locale | ||
179 | |||
180 | Layout.row: 1 | ||
181 | Layout.column: 1 | ||
182 | Layout.fillWidth: true | ||
183 | |||
184 | delegate: WrapperItem { | ||
185 | required property string shortName | ||
186 | |||
187 | width: dowLabel.contentWidth + 6 | ||
188 | |||
189 | Text { | ||
190 | id: dowLabel | ||
191 | |||
192 | anchors.fill: parent | ||
193 | |||
194 | font.pointSize: 10 | ||
195 | font.family: "Fira Sans" | ||
196 | |||
197 | text: parent.shortName | ||
198 | color: "#ffcc66" | ||
199 | |||
200 | horizontalAlignment: Text.AlignHCenter | ||
201 | verticalAlignment: Text.AlignVCenter | ||
202 | } | ||
203 | } | ||
204 | } | ||
205 | |||
206 | WeekNumberColumn { | ||
207 | month: grid.month | ||
208 | year: grid.year | ||
209 | locale: grid.locale | ||
210 | |||
211 | Layout.fillHeight: true | ||
212 | |||
213 | delegate: Text { | ||
214 | required property int weekNumber | ||
215 | |||
216 | opacity: { | ||
217 | const simple = new Date(weekNumber == 1 && monthCalendar.month == 12 ? yearCalendar.year + 1 : yearCalendar.year, 0, 1 + (weekNumber - 1) * 7); | ||
218 | const dayOfWeek = simple.getDay(); | ||
219 | const isoWeekStart = simple; | ||
220 | |||
221 | isoWeekStart.setDate(simple.getDate() - dayOfWeek + 1); | ||
222 | if (dayOfWeek > 4) { | ||
223 | isoWeekStart.setDate(isoWeekStart.getDate() + 7); | ||
224 | } | ||
225 | |||
226 | for (let i = 0; i < 7; i++) { | ||
227 | const dayInWeek = new Date(isoWeekStart); | ||
228 | dayInWeek.setDate(dayInWeek.getDate() + i); | ||
229 | if (dayInWeek.getMonth() == monthCalendar.month) | ||
230 | return 1; | ||
231 | } | ||
232 | |||
233 | return 0; | ||
234 | } | ||
235 | |||
236 | font.pointSize: 10 | ||
237 | font.family: "Fira Sans" | ||
238 | font.features: { "tnum": 1 } | ||
239 | |||
240 | text: weekNumber | ||
241 | color: "#99ffdd" | ||
242 | |||
243 | horizontalAlignment: Text.AlignRight | ||
244 | verticalAlignment: Text.AlignVCenter | ||
245 | } | ||
246 | } | ||
247 | |||
248 | MonthGrid { | ||
249 | id: grid | ||
250 | |||
251 | year: yearCalendar.year | ||
252 | month: monthCalendar.month | ||
253 | locale: Qt.locale("en_DK") | ||
254 | |||
255 | Layout.fillWidth: true | ||
256 | Layout.fillHeight: true | ||
257 | |||
258 | delegate: Text { | ||
259 | required property var model | ||
260 | |||
261 | opacity: model.month === monthCalendar.month ? 1 : 0 | ||
262 | |||
263 | font.pointSize: 10 | ||
264 | font.family: "Fira Sans" | ||
265 | font.features: { "tnum": 1 } | ||
266 | |||
267 | property bool today: chrono.date.getFullYear() == model.year && chrono.date.getMonth() == model.month && chrono.date.getDate() == model.day | ||
268 | |||
269 | text: model.day | ||
270 | color: today ? "#ff6699" : "white" | ||
271 | |||
272 | horizontalAlignment: Text.AlignRight | ||
273 | verticalAlignment: Text.AlignVCenter | ||
274 | } | ||
275 | } | ||
276 | } | ||
277 | } | ||
278 | } | ||
279 | } | ||
280 | } | ||
281 | } | ||
282 | } | ||
283 | } | ||
284 | } | ||
diff --git a/accounts/gkleen@sif/shell/quickshell/KeyboardLayout.qml b/accounts/gkleen@sif/shell/quickshell/KeyboardLayout.qml new file mode 100644 index 00000000..bc3750f9 --- /dev/null +++ b/accounts/gkleen@sif/shell/quickshell/KeyboardLayout.qml | |||
@@ -0,0 +1,106 @@ | |||
1 | import Quickshell | ||
2 | import QtQuick | ||
3 | import qs.Services | ||
4 | import Quickshell.Widgets | ||
5 | |||
6 | Item { | ||
7 | width: kbdLabel.contentWidth + 8 | ||
8 | height: parent.height | ||
9 | anchors.verticalCenter: parent.verticalCenter | ||
10 | |||
11 | WrapperMouseArea { | ||
12 | id: kbdMouseArea | ||
13 | |||
14 | anchors.fill: parent | ||
15 | |||
16 | hoverEnabled: true | ||
17 | cursorShape: Qt.PointingHandCursor | ||
18 | enabled: true | ||
19 | onClicked: { | ||
20 | NiriService.sendCommand({ "Action": { "SwitchLayout": { "layout": "Next" } } }, _ => {}) | ||
21 | } | ||
22 | onWheel: event => { | ||
23 | NiriService.sendCommand({ "Action": { "SwitchLayout": { "layout": event.angleDelta > 0 ? "Next" : "Prev" } } }, _ => {}) | ||
24 | } | ||
25 | |||
26 | Rectangle { | ||
27 | id: kbdWidget | ||
28 | |||
29 | property var keyboardAbbrev: { "English (programmer Dvorak)": "dvp", "English (US)": "us" } | ||
30 | |||
31 | anchors.fill: parent | ||
32 | color: { | ||
33 | if (kbdMouseArea.containsMouse) { | ||
34 | return "#33808080"; | ||
35 | } | ||
36 | return "transparent"; | ||
37 | } | ||
38 | |||
39 | Text { | ||
40 | id: kbdLabel | ||
41 | |||
42 | font.pointSize: 10 | ||
43 | font.family: "Fira Sans" | ||
44 | color: { | ||
45 | if (NiriService.keyboardLayouts?.current_idx === 0) | ||
46 | return "#555"; | ||
47 | return "white"; | ||
48 | } | ||
49 | anchors.centerIn: parent | ||
50 | |||
51 | text: { | ||
52 | const currentLayout = NiriService.keyboardLayouts?.names?.[NiriService.keyboardLayouts.current_idx]; | ||
53 | if (!currentLayout) | ||
54 | return ""; | ||
55 | return kbdWidget.keyboardAbbrev[currentLayout] ? kbdWidget.keyboardAbbrev[currentLayout] : currentLayout; | ||
56 | } | ||
57 | } | ||
58 | } | ||
59 | } | ||
60 | |||
61 | PopupWindow { | ||
62 | id: tooltip | ||
63 | |||
64 | property bool nextVisible: kbdMouseArea.containsMouse || tooltipMouseArea.containsMouse | ||
65 | |||
66 | anchor { | ||
67 | item: kbdMouseArea | ||
68 | edges: Edges.Bottom | Edges.Left | ||
69 | } | ||
70 | visible: false | ||
71 | |||
72 | onNextVisibleChanged: hangTimer.restart() | ||
73 | |||
74 | Timer { | ||
75 | id: hangTimer | ||
76 | interval: 100 | ||
77 | onTriggered: tooltip.visible = tooltip.nextVisible | ||
78 | } | ||
79 | |||
80 | implicitWidth: kbdTooltipText.contentWidth + 16 | ||
81 | implicitHeight: kbdTooltipText.contentHeight + 16 | ||
82 | color: "black" | ||
83 | |||
84 | WrapperMouseArea { | ||
85 | id: tooltipMouseArea | ||
86 | |||
87 | hoverEnabled: true | ||
88 | enabled: true | ||
89 | |||
90 | anchors.centerIn: parent | ||
91 | |||
92 | Text { | ||
93 | id: kbdTooltipText | ||
94 | |||
95 | font.pointSize: 10 | ||
96 | font.family: "Fira Sans" | ||
97 | color: "white" | ||
98 | |||
99 | text: { | ||
100 | const currentLayout = NiriService.keyboardLayouts?.names?.[NiriService.keyboardLayouts.current_idx]; | ||
101 | return currentLayout || ""; | ||
102 | } | ||
103 | } | ||
104 | } | ||
105 | } | ||
106 | } | ||
diff --git a/accounts/gkleen@sif/shell/quickshell/LockSurface.qml b/accounts/gkleen@sif/shell/quickshell/LockSurface.qml new file mode 100644 index 00000000..18698725 --- /dev/null +++ b/accounts/gkleen@sif/shell/quickshell/LockSurface.qml | |||
@@ -0,0 +1,223 @@ | |||
1 | import Quickshell.Widgets | ||
2 | import QtQuick.Effects | ||
3 | import QtQuick.Layouts | ||
4 | import QtQuick | ||
5 | import QtQuick.Controls | ||
6 | import QtQuick.Controls.Fusion | ||
7 | import qs.Services | ||
8 | import QtQml | ||
9 | |||
10 | Item { | ||
11 | id: lockSurface | ||
12 | |||
13 | property var screen | ||
14 | property list<var> messages: [] | ||
15 | property bool responseRequired: false | ||
16 | property bool responseVisible: false | ||
17 | property string currentText: "" | ||
18 | property bool authRunning: false | ||
19 | |||
20 | signal response(string responseText) | ||
21 | |||
22 | anchors.fill: parent | ||
23 | |||
24 | Item { | ||
25 | id: background | ||
26 | |||
27 | anchors.fill: parent | ||
28 | |||
29 | property Img current: one | ||
30 | property string source: selector.selected | ||
31 | |||
32 | WallpaperSelector { | ||
33 | id: selector | ||
34 | seed: lockSurface.screen?.name || "" | ||
35 | } | ||
36 | |||
37 | onSourceChanged: { | ||
38 | if (!source) | ||
39 | current = null; | ||
40 | else if (current === one) | ||
41 | two.update() | ||
42 | else | ||
43 | one.update() | ||
44 | } | ||
45 | |||
46 | Img { id: one } | ||
47 | Img { id: two } | ||
48 | |||
49 | component Img: Item { | ||
50 | id: img | ||
51 | |||
52 | property string source | ||
53 | |||
54 | function update() { | ||
55 | source = background.source || "" | ||
56 | } | ||
57 | |||
58 | anchors.fill: parent | ||
59 | |||
60 | Image { | ||
61 | id: imageSource | ||
62 | |||
63 | source: img.source | ||
64 | sourceSize: Qt.size(parent.width, parent.height) | ||
65 | fillMode: Image.PreserveAspectCrop | ||
66 | smooth: true | ||
67 | visible: false | ||
68 | asynchronous: true | ||
69 | cache: false | ||
70 | |||
71 | onStatusChanged: { | ||
72 | if (status === Image.Ready) { | ||
73 | background.current = img | ||
74 | } | ||
75 | } | ||
76 | } | ||
77 | |||
78 | MultiEffect { | ||
79 | id: imageEffect | ||
80 | |||
81 | source: imageSource | ||
82 | anchors.fill: parent | ||
83 | blurEnabled: true | ||
84 | blur: 1 | ||
85 | blurMax: 64 | ||
86 | blurMultiplier: 2 | ||
87 | |||
88 | opacity: 0 | ||
89 | |||
90 | states: State { | ||
91 | name: "visible" | ||
92 | when: background.current === img | ||
93 | |||
94 | PropertyChanges { | ||
95 | imageEffect.opacity: 1 | ||
96 | } | ||
97 | StateChangeScript { | ||
98 | name: "unloadOther" | ||
99 | script: { | ||
100 | if (img === one) | ||
101 | two.source = "" | ||
102 | if (img === two) | ||
103 | one.source = "" | ||
104 | } | ||
105 | } | ||
106 | } | ||
107 | |||
108 | transitions: Transition { | ||
109 | SequentialAnimation { | ||
110 | NumberAnimation { | ||
111 | target: imageEffect | ||
112 | properties: "opacity" | ||
113 | duration: 5000 | ||
114 | easing.type: Easing.OutCubic | ||
115 | } | ||
116 | ScriptAction { | ||
117 | scriptName: "unloadOther" | ||
118 | } | ||
119 | } | ||
120 | } | ||
121 | } | ||
122 | } | ||
123 | } | ||
124 | |||
125 | Item { | ||
126 | anchors { | ||
127 | top: lockSurface.top | ||
128 | left: lockSurface.left | ||
129 | right: lockSurface.right | ||
130 | } | ||
131 | |||
132 | implicitWidth: lockSurface.width | ||
133 | implicitHeight: 21 | ||
134 | |||
135 | Rectangle { | ||
136 | anchors.fill: parent | ||
137 | color: Qt.rgba(0, 0, 0, 0.75) | ||
138 | } | ||
139 | |||
140 | Clock { | ||
141 | anchors.centerIn: parent | ||
142 | calendarPopup: false | ||
143 | } | ||
144 | } | ||
145 | |||
146 | WrapperRectangle { | ||
147 | id: unlockUi | ||
148 | |||
149 | Keys.onPressed: event => { | ||
150 | if (!lockSurface.authRunning) { | ||
151 | event.accepted = true; | ||
152 | lockSurface.authRunning = true; | ||
153 | } | ||
154 | } | ||
155 | focus: !passwordBox.visible | ||
156 | |||
157 | visible: lockSurface.authRunning | ||
158 | |||
159 | color: Qt.rgba(0, 0, 0, 0.75) | ||
160 | margin: 8 | ||
161 | |||
162 | anchors.centerIn: parent | ||
163 | |||
164 | ColumnLayout { | ||
165 | spacing: 4 | ||
166 | |||
167 | BusyIndicator { | ||
168 | visible: running | ||
169 | running: !Array.from(lockSurface.messages).length && !lockSurface.responseRequired | ||
170 | } | ||
171 | |||
172 | Repeater { | ||
173 | model: lockSurface.messages | ||
174 | |||
175 | Text { | ||
176 | required property var modelData | ||
177 | |||
178 | font.pointSize: 10 | ||
179 | font.family: "Fira Sans" | ||
180 | color: modelData.error ? "#f28a21" : "#ffffff" | ||
181 | |||
182 | text: String(modelData.text).trim() | ||
183 | |||
184 | Layout.fillWidth: true | ||
185 | horizontalAlignment: Text.AlignHCenter | ||
186 | } | ||
187 | } | ||
188 | |||
189 | TextField { | ||
190 | id: passwordBox | ||
191 | |||
192 | visible: lockSurface.responseRequired | ||
193 | echoMode: lockSurface.responseVisible ? TextInput.Normal : TextInput.Password | ||
194 | inputMethodHints: Qt.ImhSensitiveData | ||
195 | |||
196 | onTextChanged: lockSurface.currentText = passwordBox.text | ||
197 | onAccepted: { | ||
198 | passwordBox.readOnly = true; | ||
199 | lockSurface.response(lockSurface.currentText); | ||
200 | } | ||
201 | |||
202 | Connections { | ||
203 | target: lockSurface | ||
204 | function onCurrentTextChanged() { | ||
205 | passwordBox.text = lockSurface.currentText | ||
206 | } | ||
207 | } | ||
208 | Connections { | ||
209 | target: lockSurface | ||
210 | function onResponseRequiredChanged() { | ||
211 | if (lockSurface.responseRequired) | ||
212 | passwordBox.readOnly = false; | ||
213 | passwordBox.focus = true; | ||
214 | passwordBox.selectAll(); | ||
215 | } | ||
216 | } | ||
217 | |||
218 | Layout.topMargin: 4 | ||
219 | Layout.fillWidth: true | ||
220 | } | ||
221 | } | ||
222 | } | ||
223 | } | ||
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 @@ | |||
1 | import Quickshell | ||
2 | import Quickshell.Wayland | ||
3 | import Quickshell.Io | ||
4 | import Quickshell.Services.Pam | ||
5 | import Quickshell.Services.Mpris | ||
6 | import Custom as Custom | ||
7 | import qs.Services | ||
8 | import QtQml | ||
9 | |||
10 | Scope { | ||
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 | } | ||
diff --git a/accounts/gkleen@sif/shell/quickshell/MaterialDesignIcon.qml b/accounts/gkleen@sif/shell/quickshell/MaterialDesignIcon.qml new file mode 100644 index 00000000..387dcc8b --- /dev/null +++ b/accounts/gkleen@sif/shell/quickshell/MaterialDesignIcon.qml | |||
@@ -0,0 +1,24 @@ | |||
1 | import QtQuick | ||
2 | import QtQuick.Effects | ||
3 | |||
4 | Item { | ||
5 | id: icon | ||
6 | |||
7 | required property string icon | ||
8 | property color color: "white" | ||
9 | |||
10 | Image { | ||
11 | id: sourceImage | ||
12 | source: "file://" + @mdi@ + "/svg/" + icon.icon + ".svg" | ||
13 | anchors.fill: parent | ||
14 | |||
15 | layer.enabled: true | ||
16 | layer.effect: MultiEffect { | ||
17 | id: effect | ||
18 | |||
19 | brightness: 1 | ||
20 | colorization: 1 | ||
21 | colorizationColor: icon.color | ||
22 | } | ||
23 | } | ||
24 | } | ||
diff --git a/accounts/gkleen@sif/shell/quickshell/PipewireWidget.qml b/accounts/gkleen@sif/shell/quickshell/PipewireWidget.qml new file mode 100644 index 00000000..7fdb5006 --- /dev/null +++ b/accounts/gkleen@sif/shell/quickshell/PipewireWidget.qml | |||
@@ -0,0 +1,354 @@ | |||
1 | import QtQuick | ||
2 | import QtQuick.Layouts | ||
3 | import QtQuick.Controls.Fusion | ||
4 | import Quickshell | ||
5 | import Quickshell.Services.Pipewire | ||
6 | import Quickshell.Widgets | ||
7 | |||
8 | Item { | ||
9 | height: parent.height | ||
10 | width: volumeIcon.width + 8 | ||
11 | anchors.verticalCenter: parent.verticalCenter | ||
12 | |||
13 | PwObjectTracker { | ||
14 | objects: [Pipewire.defaultAudioSink] | ||
15 | } | ||
16 | |||
17 | WrapperMouseArea { | ||
18 | id: widgetMouseArea | ||
19 | |||
20 | anchors.fill: parent | ||
21 | hoverEnabled: true | ||
22 | cursorShape: Qt.PointingHandCursor | ||
23 | |||
24 | onClicked: { | ||
25 | if (!Pipewire.defaultAudioSink) | ||
26 | return; | ||
27 | Pipewire.defaultAudioSink.audio.muted = !Pipewire.defaultAudioSink.audio.muted; | ||
28 | } | ||
29 | |||
30 | property real sensitivity: (1 / 40) / 120 | ||
31 | onWheel: event => { | ||
32 | if (!Pipewire.defaultAudioSink) | ||
33 | return; | ||
34 | Pipewire.defaultAudioSink.audio.volume += event.angleDelta.y * sensitivity; | ||
35 | } | ||
36 | |||
37 | Rectangle { | ||
38 | id: volumeWidget | ||
39 | |||
40 | anchors.fill: parent | ||
41 | color: { | ||
42 | if (widgetMouseArea.containsMouse) | ||
43 | return "#33808080"; | ||
44 | return "transparent"; | ||
45 | } | ||
46 | |||
47 | Item { | ||
48 | anchors.fill: parent | ||
49 | |||
50 | MaterialDesignIcon { | ||
51 | id: volumeIcon | ||
52 | |||
53 | width: 16 | ||
54 | height: 16 | ||
55 | anchors.centerIn: parent | ||
56 | |||
57 | icon: { | ||
58 | if (!Pipewire.defaultAudioSink || Pipewire.defaultAudioSink.audio.muted) | ||
59 | return "volume-off"; | ||
60 | if (Pipewire.defaultAudioSink.audio.volume <= 0.33) | ||
61 | return "volume-low"; | ||
62 | if (Pipewire.defaultAudioSink.audio.volume <= 0.67) | ||
63 | return "volume-medium"; | ||
64 | return "volume-high"; | ||
65 | } | ||
66 | color: "#555" | ||
67 | } | ||
68 | } | ||
69 | } | ||
70 | } | ||
71 | |||
72 | Loader { | ||
73 | id: tooltipLoader | ||
74 | |||
75 | active: false | ||
76 | |||
77 | Connections { | ||
78 | target: widgetMouseArea | ||
79 | function onContainsMouseChanged() { | ||
80 | if (widgetMouseArea.containsMouse) | ||
81 | tooltipLoader.active = true; | ||
82 | } | ||
83 | } | ||
84 | |||
85 | PwObjectTracker { | ||
86 | objects: Pipewire.devices | ||
87 | } | ||
88 | PwObjectTracker { | ||
89 | objects: Pipewire.nodes | ||
90 | } | ||
91 | |||
92 | sourceComponent: PopupWindow { | ||
93 | id: tooltip | ||
94 | |||
95 | property bool openPopup: false | ||
96 | property bool nextVisible: widgetMouseArea.containsMouse || tooltipMouseArea.containsMouse || openPopup | ||
97 | |||
98 | anchor { | ||
99 | item: widgetMouseArea | ||
100 | edges: Edges.Bottom | Edges.Left | ||
101 | } | ||
102 | visible: false | ||
103 | |||
104 | onNextVisibleChanged: hangTimer.restart() | ||
105 | |||
106 | Timer { | ||
107 | id: hangTimer | ||
108 | interval: 100 | ||
109 | onTriggered: { | ||
110 | tooltip.visible = tooltip.nextVisible; | ||
111 | if (!tooltip.visible) | ||
112 | tooltipLoader.active = false; | ||
113 | } | ||
114 | } | ||
115 | |||
116 | implicitWidth: tooltipContent.width | ||
117 | implicitHeight: tooltipContent.height | ||
118 | color: "black" | ||
119 | |||
120 | WrapperMouseArea { | ||
121 | id: tooltipMouseArea | ||
122 | |||
123 | hoverEnabled: true | ||
124 | enabled: true | ||
125 | |||
126 | anchors.fill: parent | ||
127 | |||
128 | WrapperItem { | ||
129 | id: tooltipContent | ||
130 | |||
131 | margin: 8 | ||
132 | bottomMargin: 8 + Math.max(0, 200 - tooltipLayout.implicitHeight) | ||
133 | |||
134 | GridLayout { | ||
135 | id: tooltipLayout | ||
136 | |||
137 | columns: 4 | ||
138 | |||
139 | Repeater { | ||
140 | model: Array.from(Pipewire.devices.values).filter(dev => dev.type == "Audio/Device") | ||
141 | |||
142 | Item { | ||
143 | id: descItem | ||
144 | |||
145 | required property var modelData | ||
146 | required property int index | ||
147 | |||
148 | Layout.column: 0 | ||
149 | Layout.row: index | ||
150 | |||
151 | implicitWidth: descText.contentWidth | ||
152 | implicitHeight: descText.contentHeight | ||
153 | |||
154 | Text { | ||
155 | id: descText | ||
156 | |||
157 | color: "white" | ||
158 | font.pointSize: 10 | ||
159 | font.family: "Fira Sans" | ||
160 | |||
161 | text: descItem.modelData.description | ||
162 | } | ||
163 | } | ||
164 | } | ||
165 | |||
166 | Repeater { | ||
167 | id: defaultSinkRepeater | ||
168 | |||
169 | model: { | ||
170 | Array.from(Pipewire.devices.values) | ||
171 | .filter(dev => dev.type == "Audio/Device") | ||
172 | .map(device => Array.from(Pipewire.nodes.values).find(node => node.type == PwNodeType.AudioSink && node.device?.id == device.id )); | ||
173 | } | ||
174 | |||
175 | Item { | ||
176 | id: defaultSinkItem | ||
177 | |||
178 | required property var modelData | ||
179 | required property int index | ||
180 | |||
181 | PwObjectTracker { | ||
182 | objects: [defaultSinkItem.modelData] | ||
183 | } | ||
184 | |||
185 | Layout.column: 1 | ||
186 | Layout.row: index | ||
187 | |||
188 | Layout.fillHeight: true | ||
189 | |||
190 | implicitWidth: 16 + 8 | ||
191 | |||
192 | WrapperMouseArea { | ||
193 | id: defaultSinkMouseArea | ||
194 | |||
195 | anchors.fill: parent | ||
196 | hoverEnabled: true | ||
197 | cursorShape: Qt.PointingHandCursor | ||
198 | |||
199 | onClicked: { | ||
200 | Pipewire.preferredDefaultAudioSink = defaultSinkItem.modelData | ||
201 | } | ||
202 | |||
203 | Rectangle { | ||
204 | id: defaultSinkWidget | ||
205 | |||
206 | anchors.fill: parent | ||
207 | color: { | ||
208 | if (defaultSinkMouseArea.containsMouse) | ||
209 | return "#33808080"; | ||
210 | return "transparent"; | ||
211 | } | ||
212 | |||
213 | MaterialDesignIcon { | ||
214 | width: 16 | ||
215 | height: 16 | ||
216 | anchors.centerIn: parent | ||
217 | |||
218 | icon: { | ||
219 | if (defaultSinkItem.modelData?.id == Pipewire.defaultAudioSink?.id) | ||
220 | return "speaker"; | ||
221 | return "speaker-off"; | ||
222 | } | ||
223 | color: icon == "speaker" ? "white" : "#555" | ||
224 | } | ||
225 | } | ||
226 | } | ||
227 | } | ||
228 | } | ||
229 | |||
230 | Repeater { | ||
231 | id: defaultSourceRepeater | ||
232 | |||
233 | model: { | ||
234 | Array.from(Pipewire.devices.values) | ||
235 | .filter(dev => dev.type == "Audio/Device") | ||
236 | .map(device => Array.from(Pipewire.nodes.values).find(node => node.type == PwNodeType.AudioSource && node.device?.id == device.id )); | ||
237 | } | ||
238 | |||
239 | Item { | ||
240 | id: defaultSourceItem | ||
241 | |||
242 | required property var modelData | ||
243 | required property int index | ||
244 | |||
245 | PwObjectTracker { | ||
246 | objects: [defaultSourceItem.modelData] | ||
247 | } | ||
248 | |||
249 | Layout.column: 2 | ||
250 | Layout.row: index | ||
251 | |||
252 | Layout.fillHeight: true | ||
253 | |||
254 | implicitWidth: 16 + 8 | ||
255 | |||
256 | WrapperMouseArea { | ||
257 | id: defaultSourceMouseArea | ||
258 | |||
259 | anchors.fill: parent | ||
260 | hoverEnabled: true | ||
261 | cursorShape: Qt.PointingHandCursor | ||
262 | |||
263 | onClicked: { | ||
264 | Pipewire.preferredDefaultAudioSource = defaultSourceItem.modelData | ||
265 | } | ||
266 | |||
267 | Rectangle { | ||
268 | id: defaultSourceWidget | ||
269 | |||
270 | anchors.fill: parent | ||
271 | color: { | ||
272 | if (defaultSourceMouseArea.containsMouse) | ||
273 | return "#33808080"; | ||
274 | return "transparent"; | ||
275 | } | ||
276 | |||
277 | MaterialDesignIcon { | ||
278 | width: 16 | ||
279 | height: 16 | ||
280 | anchors.centerIn: parent | ||
281 | |||
282 | icon: { | ||
283 | if (defaultSourceItem.modelData?.id == Pipewire.defaultAudioSource?.id) | ||
284 | return "microphone"; | ||
285 | return "microphone-off"; | ||
286 | } | ||
287 | color: icon == "microphone" ? "white" : "#555" | ||
288 | } | ||
289 | } | ||
290 | } | ||
291 | } | ||
292 | } | ||
293 | |||
294 | Repeater { | ||
295 | id: profileRepeater | ||
296 | |||
297 | model: Array.from(Pipewire.devices.values).filter(dev => dev.type == "Audio/Device") | ||
298 | |||
299 | Item { | ||
300 | id: profileItem | ||
301 | |||
302 | required property var modelData | ||
303 | required property int index | ||
304 | |||
305 | PwObjectTracker { | ||
306 | objects: [profileItem.modelData] | ||
307 | } | ||
308 | |||
309 | Layout.column: 3 | ||
310 | Layout.row: index | ||
311 | |||
312 | Layout.fillWidth: true | ||
313 | |||
314 | implicitWidth: Math.max(profileBox.implicitWidth, 300) | ||
315 | implicitHeight: profileBox.height | ||
316 | |||
317 | ComboBox { | ||
318 | id: profileBox | ||
319 | |||
320 | model: profileItem.modelData.profiles | ||
321 | |||
322 | textRole: "description" | ||
323 | valueRole: "index" | ||
324 | onActivated: profileItem.modelData.setProfile(currentValue) | ||
325 | |||
326 | anchors.fill: parent | ||
327 | |||
328 | implicitContentWidthPolicy: ComboBox.WidestText | ||
329 | |||
330 | Connections { | ||
331 | target: profileItem.modelData | ||
332 | function onCurrentProfileChanged() { | ||
333 | profileBox.currentIndex = Array.from(profileItem.modelData.profiles).findIndex(profile => profile.index == profileItem.modelData.currentProfile); | ||
334 | } | ||
335 | } | ||
336 | Component.onCompleted: { | ||
337 | profileBox.currentIndex = Array.from(profileItem.modelData.profiles).findIndex(profile => profile.index == profileItem.modelData.currentProfile); | ||
338 | } | ||
339 | |||
340 | Connections { | ||
341 | target: profileBox.popup | ||
342 | function onVisibleChanged() { | ||
343 | tooltip.openPopup = profileBox.popup.visible | ||
344 | } | ||
345 | } | ||
346 | } | ||
347 | } | ||
348 | } | ||
349 | } | ||
350 | } | ||
351 | } | ||
352 | } | ||
353 | } | ||
354 | } | ||
diff --git a/accounts/gkleen@sif/shell/quickshell/Services/GpgAgent.qml b/accounts/gkleen@sif/shell/quickshell/Services/GpgAgent.qml new file mode 100644 index 00000000..3de69535 --- /dev/null +++ b/accounts/gkleen@sif/shell/quickshell/Services/GpgAgent.qml | |||
@@ -0,0 +1,18 @@ | |||
1 | pragma Singleton | ||
2 | |||
3 | import Quickshell | ||
4 | import Quickshell.Io | ||
5 | |||
6 | Singleton { | ||
7 | id: root | ||
8 | |||
9 | Socket { | ||
10 | id: agentSocket | ||
11 | connected: true | ||
12 | path: `${Quickshell.env("XDG_RUNTIME_DIR")}/gnupg/S.gpg-agent` | ||
13 | } | ||
14 | |||
15 | function reloadAgent() { | ||
16 | agentSocket.write("RELOADAGENT\n") | ||
17 | } | ||
18 | } | ||
diff --git a/accounts/gkleen@sif/shell/quickshell/Services/NiriService.qml b/accounts/gkleen@sif/shell/quickshell/Services/NiriService.qml index 914152e1..af522ec4 100644 --- a/accounts/gkleen@sif/shell/quickshell/Services/NiriService.qml +++ b/accounts/gkleen@sif/shell/quickshell/Services/NiriService.qml | |||
@@ -13,10 +13,6 @@ Singleton { | |||
13 | property var windows: [] | 13 | property var windows: [] |
14 | readonly property string socketPath: Quickshell.env("NIRI_SOCKET") | 14 | readonly property string socketPath: Quickshell.env("NIRI_SOCKET") |
15 | 15 | ||
16 | onKeyboardLayoutsChanged: { | ||
17 | console.log(JSON.stringify(keyboardLayouts)); | ||
18 | } | ||
19 | |||
20 | function refreshOutputs() { | 16 | function refreshOutputs() { |
21 | commandSocket.sendCommand("Outputs", data => { | 17 | commandSocket.sendCommand("Outputs", data => { |
22 | outputs = data.Ok.Outputs; | 18 | outputs = data.Ok.Outputs; |
@@ -32,9 +28,12 @@ Singleton { | |||
32 | path: root.socketPath | 28 | path: root.socketPath |
33 | connected: true | 29 | connected: true |
34 | 30 | ||
31 | property bool acked: false | ||
32 | |||
35 | onConnectionStateChanged: { | 33 | onConnectionStateChanged: { |
36 | if (connected) { | 34 | if (connected) { |
37 | write('"EventStream"\n') | 35 | acked = false; |
36 | write('"EventStream"\n'); | ||
38 | } | 37 | } |
39 | } | 38 | } |
40 | 39 | ||
@@ -70,6 +69,11 @@ Singleton { | |||
70 | eventWindowUrgencyChanged(event.WindowUrgencyChanged); | 69 | eventWindowUrgencyChanged(event.WindowUrgencyChanged); |
71 | else if (event.WindowLayoutsChanged) | 70 | else if (event.WindowLayoutsChanged) |
72 | eventWindowLayoutsChanged(event.WindowLayoutsChanged); | 71 | eventWindowLayoutsChanged(event.WindowLayoutsChanged); |
72 | else if (event.Ok && !eventStreamSocket.acked) { eventStreamSocket.acked = true; } | ||
73 | else if (event.OverviewOpenedOrClosed) {} | ||
74 | else if (event.ConfigLoaded) {} | ||
75 | else | ||
76 | console.log(JSON.stringify(event)); | ||
73 | } catch (e) { | 77 | } catch (e) { |
74 | console.warn("NiriService: Failed to parse event:", line, e) | 78 | console.warn("NiriService: Failed to parse event:", line, e) |
75 | } | 79 | } |
@@ -157,10 +161,10 @@ Singleton { | |||
157 | } | 161 | } |
158 | function eventWindowOpenedOrChanged(data) { | 162 | function eventWindowOpenedOrChanged(data) { |
159 | root.windows = Array.from(root.windows).map(win => { | 163 | root.windows = Array.from(root.windows).map(win => { |
160 | if (win.id === data.window.id) | 164 | if (data.window.is_focused) |
161 | return data.window; | 165 | win.is_focused = false; |
162 | return win; | 166 | return win; |
163 | }); | 167 | }).filter(win => win.id !== data.window.id).concat([data.window]); |
164 | } | 168 | } |
165 | function eventWindowClosed(data) { | 169 | function eventWindowClosed(data) { |
166 | root.windows = Array.from(root.windows).filter(win => win.id !== data.id); | 170 | root.windows = Array.from(root.windows).filter(win => win.id !== data.id); |
diff --git a/accounts/gkleen@sif/shell/quickshell/Services/WallpaperSelector.qml b/accounts/gkleen@sif/shell/quickshell/Services/WallpaperSelector.qml new file mode 100644 index 00000000..3c524955 --- /dev/null +++ b/accounts/gkleen@sif/shell/quickshell/Services/WallpaperSelector.qml | |||
@@ -0,0 +1,8 @@ | |||
1 | import Custom as Custom | ||
2 | |||
3 | Custom.FileSelector { | ||
4 | id: root | ||
5 | |||
6 | directory: @wallpapers@ | ||
7 | epoch: 72000000 | ||
8 | } | ||
diff --git a/accounts/gkleen@sif/shell/quickshell/SystemTray.qml b/accounts/gkleen@sif/shell/quickshell/SystemTray.qml new file mode 100644 index 00000000..55b1690e --- /dev/null +++ b/accounts/gkleen@sif/shell/quickshell/SystemTray.qml | |||
@@ -0,0 +1,159 @@ | |||
1 | import QtQuick | ||
2 | import Quickshell | ||
3 | import Quickshell.Widgets | ||
4 | import Quickshell.Services.SystemTray | ||
5 | |||
6 | Item { | ||
7 | anchors.verticalCenter: parent.verticalCenter | ||
8 | width: systemTrayRow.childrenRect.width | ||
9 | height: parent.height | ||
10 | clip: true | ||
11 | |||
12 | Row { | ||
13 | id: systemTrayRow | ||
14 | anchors.centerIn: parent | ||
15 | width: childrenRect.width | ||
16 | height: parent.height | ||
17 | spacing: 0 | ||
18 | |||
19 | Repeater { | ||
20 | model: ScriptModel { | ||
21 | values: { | ||
22 | var trayItems = Array.from(SystemTray.items.values).filter(item => item.status !== Status.Passive); | ||
23 | trayItems.sort((a, b) => a.category !== b.category ? b.category - a.category : a.id.localeCompare(b.id)) | ||
24 | return trayItems; | ||
25 | } | ||
26 | } | ||
27 | |||
28 | delegate: Item { | ||
29 | id: trayItemWrapper | ||
30 | |||
31 | property var trayItem: modelData | ||
32 | property string iconSource: { | ||
33 | let icon = trayItem && trayItem.icon | ||
34 | if (typeof icon === 'string' || icon instanceof String) { | ||
35 | if (icon.includes("?path=")) { | ||
36 | const split = icon.split("?path=") | ||
37 | if (split.length !== 2) | ||
38 | return icon | ||
39 | const name = split[0] | ||
40 | const path = split[1] | ||
41 | const fileName = name.substring( | ||
42 | name.lastIndexOf("/") + 1) | ||
43 | return `file://${path}/${fileName}` | ||
44 | } | ||
45 | return icon | ||
46 | } | ||
47 | return "" | ||
48 | } | ||
49 | |||
50 | width: 16 | ||
51 | height: parent.height | ||
52 | anchors.verticalCenter: parent.verticalCenter | ||
53 | |||
54 | WrapperMouseArea { | ||
55 | id: trayItemArea | ||
56 | |||
57 | anchors.fill: parent | ||
58 | acceptedButtons: Qt.LeftButton | Qt.RightButton | ||
59 | hoverEnabled: true | ||
60 | cursorShape: trayItem.onlyMenu ? Qt.ArrowCursor : Qt.PointingHandCursor | ||
61 | onClicked: mouse => { | ||
62 | if (!trayItem) | ||
63 | return | ||
64 | |||
65 | if (mouse.button === Qt.LeftButton | ||
66 | && !trayItem.onlyMenu) { | ||
67 | trayItem.activate() | ||
68 | return | ||
69 | } | ||
70 | |||
71 | if (trayItem.hasMenu) { | ||
72 | var globalPos = mapToGlobal(0, 0) | ||
73 | var currentScreen = screen || Screen | ||
74 | var screenX = currentScreen.x || 0 | ||
75 | var relativeX = globalPos.x - screenX | ||
76 | menuAnchor.menu = trayItem.menu | ||
77 | menuAnchor.anchor.window = bar | ||
78 | menuAnchor.anchor.rect = Qt.rect( | ||
79 | relativeX, | ||
80 | 21, | ||
81 | parent.width, 1) | ||
82 | menuAnchor.open() | ||
83 | } | ||
84 | } | ||
85 | |||
86 | IconImage { | ||
87 | anchors.centerIn: parent | ||
88 | width: parent.width | ||
89 | height: parent.width | ||
90 | source: trayItemWrapper.iconSource | ||
91 | asynchronous: true | ||
92 | smooth: true | ||
93 | mipmap: true | ||
94 | } | ||
95 | } | ||
96 | |||
97 | PopupWindow { | ||
98 | id: tooltip | ||
99 | |||
100 | property bool nextVisible: (trayItem.tooltipTitle || trayItem.tooltipDescription) && (trayItemArea.containsMouse || tooltipMouseArea.containsMouse) && !menuAnchor.visible | ||
101 | |||
102 | anchor { | ||
103 | item: trayItemArea | ||
104 | edges: Edges.Bottom | ||
105 | } | ||
106 | |||
107 | visible: false | ||
108 | onNextVisibleChanged: hangTimer.restart() | ||
109 | |||
110 | Timer { | ||
111 | id: hangTimer | ||
112 | interval: 100 | ||
113 | onTriggered: tooltip.visible = tooltip.nextVisible | ||
114 | } | ||
115 | |||
116 | color: "black" | ||
117 | |||
118 | implicitWidth: Math.max(tooltipTitle.contentWidth, tooltipDescription.contentWidth) + 16 | ||
119 | implicitHeight: tooltipTitle.contentHeight + tooltipDescription.contentHeight + 16 | ||
120 | |||
121 | WrapperMouseArea { | ||
122 | id: tooltipMouseArea | ||
123 | |||
124 | hoverEnabled: true | ||
125 | enabled: true | ||
126 | |||
127 | margin: 8 | ||
128 | |||
129 | Column { | ||
130 | Text { | ||
131 | id: tooltipTitle | ||
132 | |||
133 | font.pointSize: 10 | ||
134 | font.family: "Fira Sans" | ||
135 | font.bold: true | ||
136 | color: "white" | ||
137 | |||
138 | text: trayItem.tooltipTitle | ||
139 | } | ||
140 | |||
141 | Text { | ||
142 | id: tooltipDescription | ||
143 | |||
144 | font.pointSize: 10 | ||
145 | font.family: "Fira Sans" | ||
146 | color: "white" | ||
147 | |||
148 | text: trayItem.tooltipDescription | ||
149 | } | ||
150 | } | ||
151 | } | ||
152 | } | ||
153 | } | ||
154 | } | ||
155 | } | ||
156 | QsMenuAnchor { | ||
157 | id: menuAnchor | ||
158 | } | ||
159 | } | ||
diff --git a/accounts/gkleen@sif/shell/quickshell/VolumeOSD.qml b/accounts/gkleen@sif/shell/quickshell/VolumeOSD.qml new file mode 100644 index 00000000..02dcf227 --- /dev/null +++ b/accounts/gkleen@sif/shell/quickshell/VolumeOSD.qml | |||
@@ -0,0 +1,134 @@ | |||
1 | import QtQuick | ||
2 | import QtQuick.Layouts | ||
3 | import Quickshell | ||
4 | import Quickshell.Services.Pipewire | ||
5 | import Quickshell.Widgets | ||
6 | |||
7 | Scope { | ||
8 | id: root | ||
9 | |||
10 | property bool show: false | ||
11 | property bool inhibited: true | ||
12 | |||
13 | PwObjectTracker { | ||
14 | objects: [ Pipewire.defaultAudioSink ] | ||
15 | } | ||
16 | |||
17 | Connections { | ||
18 | enabled: Pipewire.defaultAudioSink | ||
19 | target: Pipewire.defaultAudioSink?.audio | ||
20 | |||
21 | function onVolumeChanged() { | ||
22 | root.show = true; | ||
23 | hideTimer.restart(); | ||
24 | } | ||
25 | function onMutedChanged() { | ||
26 | root.show = true; | ||
27 | hideTimer.restart(); | ||
28 | } | ||
29 | } | ||
30 | |||
31 | onShowChanged: { | ||
32 | if (show) | ||
33 | hideTimer.restart(); | ||
34 | } | ||
35 | |||
36 | Timer { | ||
37 | id: hideTimer | ||
38 | interval: 1000 | ||
39 | onTriggered: root.show = false | ||
40 | } | ||
41 | |||
42 | Timer { | ||
43 | id: startInhibit | ||
44 | interval: 100 | ||
45 | running: true | ||
46 | onTriggered: { | ||
47 | root.show = false; | ||
48 | root.inhibited = false; | ||
49 | } | ||
50 | } | ||
51 | |||
52 | LazyLoader { | ||
53 | active: root.show && !root.inhibited | ||
54 | |||
55 | Variants { | ||
56 | model: Quickshell.screens | ||
57 | |||
58 | delegate: Scope { | ||
59 | id: screenScope | ||
60 | |||
61 | required property var modelData | ||
62 | |||
63 | PanelWindow { | ||
64 | id: window | ||
65 | |||
66 | screen: screenScope.modelData | ||
67 | |||
68 | anchors.top: true | ||
69 | margins.top: screen.height / 2 - 50 + 3.5 | ||
70 | exclusiveZone: 0 | ||
71 | exclusionMode: ExclusionMode.Ignore | ||
72 | |||
73 | implicitWidth: 400 | ||
74 | implicitHeight: 50 | ||
75 | |||
76 | mask: Region {} | ||
77 | |||
78 | color: "transparent" | ||
79 | |||
80 | Rectangle { | ||
81 | anchors.fill: parent | ||
82 | color: Qt.rgba(0, 0, 0, 0.75) | ||
83 | } | ||
84 | |||
85 | RowLayout { | ||
86 | id: layout | ||
87 | |||
88 | anchors.centerIn: parent | ||
89 | |||
90 | height: 50 - 8*2 | ||
91 | width: 400 - 8*2 | ||
92 | |||
93 | MaterialDesignIcon { | ||
94 | id: volumeIcon | ||
95 | |||
96 | implicitWidth: parent.height | ||
97 | implicitHeight: parent.height | ||
98 | |||
99 | icon: { | ||
100 | if (!Pipewire.defaultAudioSink || Pipewire.defaultAudioSink.audio.muted) | ||
101 | return "volume-off"; | ||
102 | if (Pipewire.defaultAudioSink.audio.volume <= 0.33) | ||
103 | return "volume-low"; | ||
104 | if (Pipewire.defaultAudioSink.audio.volume <= 0.67) | ||
105 | return "volume-medium"; | ||
106 | return "volume-high"; | ||
107 | } | ||
108 | } | ||
109 | |||
110 | Rectangle { | ||
111 | Layout.fillWidth: true | ||
112 | |||
113 | implicitHeight: 10 | ||
114 | |||
115 | color: "#50ffffff" | ||
116 | |||
117 | Rectangle { | ||
118 | anchors { | ||
119 | left: parent.left | ||
120 | top: parent.top | ||
121 | bottom: parent.bottom | ||
122 | } | ||
123 | |||
124 | color: Pipewire.defaultAudioSink?.audio.muted ? "#70ffffff" : "white" | ||
125 | |||
126 | implicitWidth: parent.width * (Pipewire.defaultAudioSink?.audio.volume ?? 0) | ||
127 | } | ||
128 | } | ||
129 | } | ||
130 | } | ||
131 | } | ||
132 | } | ||
133 | } | ||
134 | } | ||
diff --git a/accounts/gkleen@sif/shell/quickshell/WallpaperBackground.qml b/accounts/gkleen@sif/shell/quickshell/WallpaperBackground.qml new file mode 100644 index 00000000..de31915f --- /dev/null +++ b/accounts/gkleen@sif/shell/quickshell/WallpaperBackground.qml | |||
@@ -0,0 +1,85 @@ | |||
1 | import QtQuick | ||
2 | import Quickshell | ||
3 | import qs.Services | ||
4 | |||
5 | Item { | ||
6 | id: root | ||
7 | |||
8 | anchors.fill: parent | ||
9 | |||
10 | required property string screen | ||
11 | |||
12 | property Img current: one | ||
13 | property string source: selector.selected | ||
14 | |||
15 | WallpaperSelector { | ||
16 | id: selector | ||
17 | seed: screen | ||
18 | } | ||
19 | |||
20 | onSourceChanged: { | ||
21 | if (!source) | ||
22 | current = null; | ||
23 | else if (current === one) | ||
24 | two.update() | ||
25 | else | ||
26 | one.update() | ||
27 | } | ||
28 | |||
29 | Img { id: one } | ||
30 | Img { id: two } | ||
31 | |||
32 | component Img: Image { | ||
33 | id: img | ||
34 | |||
35 | function update() { | ||
36 | source = root.source || "" | ||
37 | } | ||
38 | |||
39 | anchors.fill: parent | ||
40 | fillMode: Image.PreserveAspectCrop | ||
41 | smooth: true | ||
42 | asynchronous: true | ||
43 | cache: false | ||
44 | |||
45 | opacity: 0 | ||
46 | |||
47 | onStatusChanged: { | ||
48 | if (status === Image.Ready) { | ||
49 | root.current = this | ||
50 | } | ||
51 | } | ||
52 | |||
53 | states: State { | ||
54 | name: "visible" | ||
55 | when: root.current === img | ||
56 | |||
57 | PropertyChanges { | ||
58 | img.opacity: 1 | ||
59 | } | ||
60 | StateChangeScript { | ||
61 | name: "unloadOther" | ||
62 | script: { | ||
63 | if (img === one) | ||
64 | two.source = "" | ||
65 | if (img === two) | ||
66 | one.source = "" | ||
67 | } | ||
68 | } | ||
69 | } | ||
70 | |||
71 | transitions: Transition { | ||
72 | SequentialAnimation { | ||
73 | NumberAnimation { | ||
74 | target: img | ||
75 | properties: "opacity" | ||
76 | duration: 5000 | ||
77 | easing.type: Easing.OutCubic | ||
78 | } | ||
79 | ScriptAction { | ||
80 | scriptName: "unloadOther" | ||
81 | } | ||
82 | } | ||
83 | } | ||
84 | } | ||
85 | } | ||
diff --git a/accounts/gkleen@sif/shell/quickshell/WorkspaceSwitcher.qml b/accounts/gkleen@sif/shell/quickshell/WorkspaceSwitcher.qml new file mode 100644 index 00000000..c8c017c3 --- /dev/null +++ b/accounts/gkleen@sif/shell/quickshell/WorkspaceSwitcher.qml | |||
@@ -0,0 +1,201 @@ | |||
1 | import Quickshell | ||
2 | import QtQuick | ||
3 | import qs.Services | ||
4 | import Quickshell.Widgets | ||
5 | import QtQuick.Layouts | ||
6 | |||
7 | Row { | ||
8 | id: workspaces | ||
9 | |||
10 | property var ignoreWorkspaces: @ignore_workspaces@ | ||
11 | |||
12 | height: parent.height | ||
13 | anchors.verticalCenter: parent.verticalCenter | ||
14 | spacing: 0 | ||
15 | |||
16 | Repeater { | ||
17 | model: ScriptModel { | ||
18 | values: { | ||
19 | let currWorkspaces = NiriService.workspaces; | ||
20 | const ignoreWorkspaces = Array.from(workspaces.ignoreWorkspaces); | ||
21 | currWorkspaces = currWorkspaces.filter(ws => ws.is_active || ignoreWorkspaces.every(iws => iws !== ws.name)); | ||
22 | currWorkspaces.sort((a, b) => { | ||
23 | if (NiriService.outputs?.[a.output]?.logical?.x !== NiriService.outputs?.[b.output]?.logical?.x) | ||
24 | return NiriService.outputs?.[a.output]?.logical?.x - NiriService.outputs?.[b.output]?.logical?.x | ||
25 | if (NiriService.outputs?.[a.output]?.logical?.y !== NiriService.outputs?.[b.output]?.logical?.y) | ||
26 | return NiriService.outputs?.[a.output]?.logical?.y - NiriService.outputs?.[b.output]?.logical?.y | ||
27 | return a.idx - b.idx; | ||
28 | }); | ||
29 | return currWorkspaces; | ||
30 | } | ||
31 | } | ||
32 | |||
33 | Item { | ||
34 | id: wsItem | ||
35 | |||
36 | property var workspaceData: modelData | ||
37 | |||
38 | width: wsLabel.contentWidth + 8 | ||
39 | height: parent.height | ||
40 | anchors.verticalCenter: parent.verticalCenter | ||
41 | |||
42 | WrapperMouseArea { | ||
43 | id: mouseArea | ||
44 | |||
45 | anchors.fill: parent | ||
46 | |||
47 | hoverEnabled: true | ||
48 | cursorShape: Qt.PointingHandCursor | ||
49 | enabled: true | ||
50 | onClicked: { | ||
51 | NiriService.sendCommand({ "Action": { "FocusWorkspace": { "reference": { "Id": workspaceData.id } } } }, _ => {}) | ||
52 | } | ||
53 | |||
54 | Rectangle { | ||
55 | anchors.fill: parent | ||
56 | |||
57 | color: { | ||
58 | if (mouseArea.containsMouse) { | ||
59 | return "#33808080"; | ||
60 | } | ||
61 | return "transparent"; | ||
62 | } | ||
63 | |||
64 | Text { | ||
65 | id: wsLabel | ||
66 | |||
67 | anchors.centerIn: parent | ||
68 | |||
69 | font.pointSize: 10 | ||
70 | font.family: "Fira Sans" | ||
71 | color: { | ||
72 | if (workspaceData.is_active) | ||
73 | return "#23fd00"; | ||
74 | if (workspaceData.active_window_id === null) | ||
75 | return "#555"; | ||
76 | return "white"; | ||
77 | } | ||
78 | |||
79 | text: workspaceData.name ? workspaceData.name : workspaceData.idx | ||
80 | } | ||
81 | } | ||
82 | } | ||
83 | |||
84 | PopupWindow { | ||
85 | id: tooltip | ||
86 | |||
87 | property bool nextVisible: (mouseArea.containsMouse || tooltipMouseArea.containsMouse) && [...windowsModel.values].length > 0 | ||
88 | |||
89 | anchor { | ||
90 | item: mouseArea | ||
91 | edges: Edges.Bottom | Edges.Left | ||
92 | } | ||
93 | visible: false | ||
94 | |||
95 | onNextVisibleChanged: hangTimer.restart() | ||
96 | |||
97 | Timer { | ||
98 | id: hangTimer | ||
99 | interval: 100 | ||
100 | onTriggered: tooltip.visible = tooltip.nextVisible | ||
101 | } | ||
102 | |||
103 | implicitWidth: tooltipContent.implicitWidth | ||
104 | implicitHeight: tooltipContent.implicitHeight | ||
105 | color: "black" | ||
106 | |||
107 | WrapperMouseArea { | ||
108 | id: tooltipMouseArea | ||
109 | |||
110 | hoverEnabled: true | ||
111 | enabled: true | ||
112 | |||
113 | anchors.fill: parent | ||
114 | |||
115 | WrapperItem { | ||
116 | id: tooltipContent | ||
117 | |||
118 | margin: 0 | ||
119 | |||
120 | ColumnLayout { | ||
121 | spacing: 0 | ||
122 | |||
123 | Repeater { | ||
124 | model: ScriptModel { | ||
125 | id: windowsModel | ||
126 | |||
127 | values: { | ||
128 | let currWindows = Array.from(NiriService.windows).filter(win => win.workspace_id == wsItem.workspaceData.id); | ||
129 | currWindows.sort((a, b) => { | ||
130 | if (a.is_floating !== b.is_floating) | ||
131 | return b.is_floating - a.is_floating; | ||
132 | if (a.layout.tile_pos_in_workspace_view?.[0] !== b.layout.tile_pos_in_workspace_view?.[0]) | ||
133 | return a.layout.tile_pos_in_workspace_view?.[0] - b.layout.tile_pos_in_workspace_view?.[0] | ||
134 | if (a.layout.tile_pos_in_workspace_view?.[1] !== b.layout.tile_pos_in_workspace_view?.[1]) | ||
135 | return a.layout.tile_pos_in_workspace_view?.[1] - b.layout.tile_pos_in_workspace_view?.[1] | ||
136 | if (a.layout.pos_in_scrolling_layout?.[0] !== b.layout.pos_in_scrolling_layout?.[0]) | ||
137 | return a.layout.pos_in_scrolling_layout?.[0] - b.layout.pos_in_scrolling_layout?.[0] | ||
138 | if (a.layout.pos_in_scrolling_layout?.[1] !== b.layout.pos_in_scrolling_layout?.[1]) | ||
139 | return a.layout.pos_in_scrolling_layout?.[1] - b.layout.pos_in_scrolling_layout?.[1] | ||
140 | if (a.app_id !== b.app_id) | ||
141 | return a.app_id.localeCompare(b.app_id); | ||
142 | |||
143 | return a.title.localeCompare(b.title); | ||
144 | }); | ||
145 | return currWindows; | ||
146 | } | ||
147 | } | ||
148 | |||
149 | WrapperMouseArea { | ||
150 | id: windowMouseArea | ||
151 | |||
152 | property var windowData: modelData | ||
153 | |||
154 | hoverEnabled: true | ||
155 | cursorShape: Qt.PointingHandCursor | ||
156 | enabled: true | ||
157 | |||
158 | Layout.fillWidth: true | ||
159 | |||
160 | onClicked: { | ||
161 | NiriService.sendCommand({ "Action": { "FocusWindow": { "id": windowData.id } } }, _ => {}) | ||
162 | } | ||
163 | |||
164 | WrapperRectangle { | ||
165 | color: windowMouseArea.containsMouse ? "#33808080" : "transparent"; | ||
166 | |||
167 | anchors.fill: parent | ||
168 | |||
169 | WrapperItem { | ||
170 | anchors.fill: parent | ||
171 | |||
172 | margin: 4 | ||
173 | |||
174 | Text { | ||
175 | id: windowLabel | ||
176 | |||
177 | font.pointSize: 10 | ||
178 | font.family: "Fira Sans" | ||
179 | color: { | ||
180 | if (windowData.is_focused) | ||
181 | return "#23fd00"; | ||
182 | if (NiriService.workspaces.find(ws => ws.id == windowData.workspace_id)?.active_window_id == windowData.id) | ||
183 | return "white"; | ||
184 | return "#555"; | ||
185 | } | ||
186 | |||
187 | text: windowData.title | ||
188 | |||
189 | horizontalAlignment: Text.AlignLeft | ||
190 | } | ||
191 | } | ||
192 | } | ||
193 | } | ||
194 | } | ||
195 | } | ||
196 | } | ||
197 | } | ||
198 | } | ||
199 | } | ||
200 | } | ||
201 | } | ||
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 | } | ||
diff --git a/accounts/gkleen@sif/shell/quickshell/shell.qml b/accounts/gkleen@sif/shell/quickshell/shell.qml index 2abd1fef..3657f77f 100644 --- a/accounts/gkleen@sif/shell/quickshell/shell.qml +++ b/accounts/gkleen@sif/shell/quickshell/shell.qml | |||
@@ -1,6 +1,7 @@ | |||
1 | //@ pragma UseQApplication | 1 | //@ pragma UseQApplication |
2 | 2 | ||
3 | import Quickshell | 3 | import Quickshell |
4 | import Quickshell.Wayland | ||
4 | 5 | ||
5 | ShellRoot { | 6 | ShellRoot { |
6 | settings.watchFiles: false | 7 | settings.watchFiles: false |
@@ -8,8 +9,38 @@ ShellRoot { | |||
8 | Variants { | 9 | Variants { |
9 | model: Quickshell.screens | 10 | model: Quickshell.screens |
10 | 11 | ||
11 | delegate: Bar { | 12 | delegate: Scope { |
12 | modelData: item | 13 | id: screenScope |
14 | |||
15 | required property var modelData | ||
16 | |||
17 | PanelWindow { | ||
18 | id: bgWindow | ||
19 | |||
20 | screen: screenScope.modelData | ||
21 | |||
22 | WlrLayershell.layer: WlrLayer.Background | ||
23 | WlrLayershell.exclusionMode: ExclusionMode.Ignore | ||
24 | |||
25 | anchors.top: true | ||
26 | anchors.bottom: true | ||
27 | anchors.left: true | ||
28 | anchors.right: true | ||
29 | |||
30 | color: "black" | ||
31 | |||
32 | WallpaperBackground { | ||
33 | screen: bgWindow.screen.name | ||
34 | } | ||
35 | } | ||
36 | |||
37 | Bar { | ||
38 | screen: screenScope.modelData | ||
39 | } | ||
13 | } | 40 | } |
14 | } | 41 | } |
42 | |||
43 | Lockscreen {} | ||
44 | |||
45 | VolumeOSD {} | ||
15 | } | 46 | } |