From ab3fa11a4b0a5e2dc999d91d98269b3204f0aaa3 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Wed, 7 Oct 2026 18:47:14 +0200 Subject: refactor: move the workspace icon map to a shared singleton The island's clock pill shows the same desktop icon the window switcher does. One map, symlinked into both components like Theme.qml, rather than a second copy that would drift. Co-Authored-By: Claude Opus 5.5 --- window-switcher/Windows.qml | 24 +++--------------------- window-switcher/Workspaces.qml | 1 + 2 files changed, 4 insertions(+), 21 deletions(-) create mode 120000 window-switcher/Workspaces.qml (limited to 'window-switcher') 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 -- cgit v1.2.3