diff options
| l--------- | desktop/Workspaces.qml | 1 | ||||
| -rw-r--r-- | shared/Workspaces.qml | 39 | ||||
| -rw-r--r-- | window-switcher/Windows.qml | 24 | ||||
| l--------- | window-switcher/Workspaces.qml | 1 |
4 files changed, 44 insertions, 21 deletions
diff --git a/desktop/Workspaces.qml b/desktop/Workspaces.qml new file mode 120000 index 0000000..712f3d6 --- /dev/null +++ b/desktop/Workspaces.qml @@ -0,0 +1 @@ +../shared/Workspaces.qml
\ No newline at end of file diff --git a/shared/Workspaces.qml b/shared/Workspaces.qml new file mode 100644 index 0000000..ca4f5b0 --- /dev/null +++ b/shared/Workspaces.qml @@ -0,0 +1,39 @@ +// Copyright (C) 2026 Danilo M. <danix@danix.xyz> +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2 as +// published by the Free Software Foundation. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +pragma Singleton + +import Quickshell +import QtQuick + +// The desktop icon for each workspace, the eight waybar drew and the window +// switcher and the island show. Names, not paths: they are resolved through +// the active icon theme, so an icon theme switch changes them everywhere. +// A named workspace, or one past eight, has none, and callers fall back to +// its number. +Singleton { + readonly property var icons: ({ + 1: "web-browser", + 2: "text-editor", + 3: "utilities-terminal", + 4: "network-server", + 5: "document-edit", + 6: "applications-graphics", + 7: "dialog-messages", + 8: "input-gaming", + }) + + function icon(name) { + const n = parseInt(String(name), 10); + if (isNaN(n)) return ""; + return icons[n] ?? ""; + } +} diff --git a/window-switcher/Windows.qml b/window-switcher/Windows.qml index ec86ee5..bfd176a 100644 --- a/window-switcher/Windows.qml +++ b/window-switcher/Windows.qml @@ -65,27 +65,9 @@ Singleton { Hyprland.dispatch(`hl.dsp.window.close({ window = "address:${addressOf(toplevel)}" })`); } - // The desktop marker on a card is the same icon waybar's bar draws for that - // workspace, so the switcher and the bar agree. waybar keeps them as CSS - // background images by workspace number (styles/modules.css); the names are - // repeated here and resolved through the active icon theme, because a - // QML-side icon has to go by name. A named workspace, or one past eight, - // has no icon and the card falls back to its number. - readonly property var workspaceIcons: ({ - 1: "web-browser", - 2: "text-editor", - 3: "utilities-terminal", - 4: "network-server", - 5: "document-edit", - 6: "applications-graphics", - 7: "dialog-messages", - 8: "input-gaming", - }) - + // The desktop marker on a card is the same icon the island and the old + // waybar bar show for that workspace; the map lives in Workspaces.qml. function workspaceIcon(workspace) { - if (!workspace) return ""; - const n = parseInt(String(workspace.name), 10); - if (isNaN(n)) return ""; - return root.workspaceIcons[n] ?? ""; + return workspace ? Workspaces.icon(workspace.name) : ""; } } diff --git a/window-switcher/Workspaces.qml b/window-switcher/Workspaces.qml new file mode 120000 index 0000000..712f3d6 --- /dev/null +++ b/window-switcher/Workspaces.qml @@ -0,0 +1 @@ +../shared/Workspaces.qml
\ No newline at end of file |
