From 9fc966ff7726d01267a6220483fb005c0efaa9c0 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sun, 31 Aug 2025 12:12:23 +0200 Subject: ... --- .../shell/quickshell/WorkspaceSwitcher.qml | 71 ++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 accounts/gkleen@sif/shell/quickshell/WorkspaceSwitcher.qml (limited to 'accounts/gkleen@sif/shell/quickshell/WorkspaceSwitcher.qml') 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 @@ +import QtQuick +import qs.Services + +Row { + id: workspaces + + property var ignoreWorkspaces: @ignore_workspaces@ + + height: parent.height + anchors.verticalCenter: parent.verticalCenter + spacing: 0 + + Repeater { + model: { + let currWorkspaces = NiriService.workspaces; + const ignoreWorkspaces = Array.from(workspaces.ignoreWorkspaces); + currWorkspaces = currWorkspaces.filter(ws => ws.is_active || ignoreWorkspaces.every(iws => iws !== ws.name)); + currWorkspaces.sort((a, b) => { + if (NiriService.outputs?.[a.output]?.logical?.x !== NiriService.outputs?.[b.output]?.logical?.x) + return NiriService.outputs?.[a.output]?.logical?.x - NiriService.outputs?.[b.output]?.logical?.x + if (NiriService.outputs?.[a.output]?.logical?.y !== NiriService.outputs?.[b.output]?.logical?.y) + return NiriService.outputs?.[a.output]?.logical?.y - NiriService.outputs?.[b.output]?.logical?.y + return a.idx - b.idx; + }); + return currWorkspaces; + } + + Rectangle { + property var workspaceData: modelData + + width: wsLabel.contentWidth + 8 + color: { + if (mouseArea.containsMouse) { + return "#33808080"; + } + return "transparent"; + } + height: parent.height + anchors.verticalCenter: parent.verticalCenter + + MouseArea { + id: mouseArea + + anchors.fill: parent + hoverEnabled: true + cursorShape: Qt.PointingHandCursor + enabled: true + onClicked: { + NiriService.sendCommand({ "Action": { "FocusWorkspace": { "reference": { "Id": workspaceData.id } } } }, _ => {}) + } + } + + Text { + id: wsLabel + + font.pointSize: 10 + font.family: "Fira Sans" + color: { + if (workspaceData.is_active) + return "#23fd00"; + if (workspaceData.active_window_id === null) + return "#555"; + return "white"; + } + anchors.centerIn: parent + + text: workspaceData.name ? workspaceData.name : workspaceData.idx + } + } + } +} \ No newline at end of file -- cgit v1.2.3