summaryrefslogtreecommitdiff
path: root/accounts/gkleen@sif/shell/quickshell/WorkspaceSwitcher.qml
diff options
context:
space:
mode:
Diffstat (limited to 'accounts/gkleen@sif/shell/quickshell/WorkspaceSwitcher.qml')
-rw-r--r--accounts/gkleen@sif/shell/quickshell/WorkspaceSwitcher.qml71
1 files changed, 71 insertions, 0 deletions
diff --git a/accounts/gkleen@sif/shell/quickshell/WorkspaceSwitcher.qml b/accounts/gkleen@sif/shell/quickshell/WorkspaceSwitcher.qml
new file mode 100644
index 00000000..153c56bb
--- /dev/null
+++ b/accounts/gkleen@sif/shell/quickshell/WorkspaceSwitcher.qml
@@ -0,0 +1,71 @@
1import QtQuick
2import qs.Services
3
4Row {
5 id: workspaces
6
7 property var ignoreWorkspaces: @ignore_workspaces@
8
9 height: parent.height
10 anchors.verticalCenter: parent.verticalCenter
11 spacing: 0
12
13 Repeater {
14 model: {
15 let currWorkspaces = NiriService.workspaces;
16 const ignoreWorkspaces = Array.from(workspaces.ignoreWorkspaces);
17 currWorkspaces = currWorkspaces.filter(ws => ws.is_active || ignoreWorkspaces.every(iws => iws !== ws.name));
18 currWorkspaces.sort((a, b) => {
19 if (NiriService.outputs?.[a.output]?.logical?.x !== NiriService.outputs?.[b.output]?.logical?.x)
20 return NiriService.outputs?.[a.output]?.logical?.x - NiriService.outputs?.[b.output]?.logical?.x
21 if (NiriService.outputs?.[a.output]?.logical?.y !== NiriService.outputs?.[b.output]?.logical?.y)
22 return NiriService.outputs?.[a.output]?.logical?.y - NiriService.outputs?.[b.output]?.logical?.y
23 return a.idx - b.idx;
24 });
25 return currWorkspaces;
26 }
27
28 Rectangle {
29 property var workspaceData: modelData
30
31 width: wsLabel.contentWidth + 8
32 color: {
33 if (mouseArea.containsMouse) {
34 return "#33808080";
35 }
36 return "transparent";
37 }
38 height: parent.height
39 anchors.verticalCenter: parent.verticalCenter
40
41 MouseArea {
42 id: mouseArea
43
44 anchors.fill: parent
45 hoverEnabled: true
46 cursorShape: Qt.PointingHandCursor
47 enabled: true
48 onClicked: {
49 NiriService.sendCommand({ "Action": { "FocusWorkspace": { "reference": { "Id": workspaceData.id } } } }, _ => {})
50 }
51 }
52
53 Text {
54 id: wsLabel
55
56 font.pointSize: 10
57 font.family: "Fira Sans"
58 color: {
59 if (workspaceData.is_active)
60 return "#23fd00";
61 if (workspaceData.active_window_id === null)
62 return "#555";
63 return "white";
64 }
65 anchors.centerIn: parent
66
67 text: workspaceData.name ? workspaceData.name : workspaceData.idx
68 }
69 }
70 }
71} \ No newline at end of file