From 805bde839f03d0e07ba3456ff26ccf527c8bd07a Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Sat, 12 Sep 2026 11:04:21 +0200 Subject: refactor: one Theme.qml in shared/, symlinked from each component The four copies had already drifted, which is the argument for doing this now rather than when a palette change has to be made four times and lands in three of them. vm-manager was missing surfaceAlt; volume-osd was missing green, yellow and surfaceAlt. The shared file is the superset, so the two thin ones gain properties they never had and nothing loses one. A symlink rather than a shared import path: a singleton outside the config directory needs a qmldir beside it, the same friction that already keeps the generated palette parsed rather than imported. Quickshell follows the link and resolves the singleton with no qmldir, so no consumer changes and no component stops running standalone under qs -p. All four load clean with Configuration Loaded and no QML resolution error. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01TvHeJEXJzdfAaCCYqURAWp --- AGENTS.md | 12 ++++++++- appearance/Theme.qml | 67 +------------------------------------------------ mail-overview/Theme.qml | 67 +------------------------------------------------ shared/Theme.qml | 66 ++++++++++++++++++++++++++++++++++++++++++++++++ vm-manager/Theme.qml | 65 +---------------------------------------------- volume-osd/Theme.qml | 61 +------------------------------------------- 6 files changed, 81 insertions(+), 257 deletions(-) mode change 100644 => 120000 appearance/Theme.qml mode change 100644 => 120000 mail-overview/Theme.qml create mode 100644 shared/Theme.qml mode change 100644 => 120000 vm-manager/Theme.qml mode change 100644 => 120000 volume-osd/Theme.qml diff --git a/AGENTS.md b/AGENTS.md index 4ef879f..3a2e504 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -109,7 +109,7 @@ No component defines a palette. `udt-accent`, in the `unified-desktop-theme` repo alongside this one, writes `~/.cache/wal/udt-palette.qml` from its `palette.rasi`, carrying the whole Catppuccin Macchiato palette plus the accent snapped from the current -wallpaper. Each `Theme.qml` parses and watches that file, so a palette edit +wallpaper. `Theme.qml` parses and watches that file, so a palette edit recolours a running shell with no restart. What is left in `Theme.qml` is a fallback for before the file is read, and for @@ -120,6 +120,16 @@ The file is parsed rather than imported because a generated QML singleton cannot be imported without a `qmldir` beside it, and the wal cache has no reason to carry one. +There is one `Theme.qml`, in `shared/`, and each component holds a symlink to +it. It was four copies that had already drifted: `vm-manager` was missing +`surfaceAlt` and `volume-osd` was missing `green`, `yellow` and `surfaceAlt`, +so the shared file is the superset and the two thin ones gained properties +they never had. A symlink rather than a shared import path because a singleton +outside the config directory needs a `qmldir`, which is the same friction that +keeps the palette parsed rather than imported; quickshell follows the link and +resolves the singleton with no qmldir and no consumer change. Editing any +component's `Theme.qml` edits all four. Do not replace a link with a copy. + ## Blur Translucency is set in QML; the frosting is the compositor's. Hyprland blurs a diff --git a/appearance/Theme.qml b/appearance/Theme.qml deleted file mode 100644 index 423dd49..0000000 --- a/appearance/Theme.qml +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (C) 2026 Danilo M. -// -// 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 Quickshell.Io -import QtQuick - -// The palette comes from unified-desktop-theme: udt-accent writes -// ~/.cache/wal/udt-palette.qml on every wallpaper change, holding the -// Macchiato colours from its palette.rasi plus the accent snapped from the -// wallpaper. Watching that file is what makes a theme edit show up here. -// -// The defaults below are only what renders before the file is read, or on a -// machine where unified-desktop-theme is not installed. -Singleton { - id: root - - property color base: "#24273a" - property color surface: "#363a4f" - property color text: "#cad3f5" - property color subtext: "#a5adcb" - property color red: "#ed8796" - property color green: "#a6da95" - property color yellow: "#eed49f" - property color surfaceAlt: "#494d64" - property color overlay: "#6e738d" - property color accent: "#b7bdf8" - - readonly property string fontFamily: "Noto Sans" - readonly property int fontSize: 16 - - // Parsed rather than imported: a generated file cannot be a QML import - // without a qmldir next to it, and the cache directory has no reason to - // carry one. The format is fixed and machine-written, so a regex is enough. - FileView { - path: `${Quickshell.env("HOME")}/.cache/wal/udt-palette.qml` - watchChanges: true - onFileChanged: reload() - onLoaded: { - const pick = key => { - const m = text().match(new RegExp(`property color ${key}: "(#[0-9a-fA-F]{6})"`)); - return m ? m[1] : null; - }; - root.base = pick("base") ?? root.base; - root.surface = pick("surface0") ?? root.surface; - root.text = pick("text") ?? root.text; - root.subtext = pick("subtext0") ?? root.subtext; - root.red = pick("red") ?? root.red; - root.green = pick("green") ?? root.green; - root.yellow = pick("yellow") ?? root.yellow; - root.surfaceAlt = pick("surface1") ?? root.surfaceAlt; - root.overlay = pick("overlay0") ?? root.overlay; - root.accent = pick("accent") ?? root.accent; - } - } -} diff --git a/appearance/Theme.qml b/appearance/Theme.qml new file mode 120000 index 0000000..3d2e40f --- /dev/null +++ b/appearance/Theme.qml @@ -0,0 +1 @@ +../shared/Theme.qml \ No newline at end of file diff --git a/mail-overview/Theme.qml b/mail-overview/Theme.qml deleted file mode 100644 index 423dd49..0000000 --- a/mail-overview/Theme.qml +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (C) 2026 Danilo M. -// -// 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 Quickshell.Io -import QtQuick - -// The palette comes from unified-desktop-theme: udt-accent writes -// ~/.cache/wal/udt-palette.qml on every wallpaper change, holding the -// Macchiato colours from its palette.rasi plus the accent snapped from the -// wallpaper. Watching that file is what makes a theme edit show up here. -// -// The defaults below are only what renders before the file is read, or on a -// machine where unified-desktop-theme is not installed. -Singleton { - id: root - - property color base: "#24273a" - property color surface: "#363a4f" - property color text: "#cad3f5" - property color subtext: "#a5adcb" - property color red: "#ed8796" - property color green: "#a6da95" - property color yellow: "#eed49f" - property color surfaceAlt: "#494d64" - property color overlay: "#6e738d" - property color accent: "#b7bdf8" - - readonly property string fontFamily: "Noto Sans" - readonly property int fontSize: 16 - - // Parsed rather than imported: a generated file cannot be a QML import - // without a qmldir next to it, and the cache directory has no reason to - // carry one. The format is fixed and machine-written, so a regex is enough. - FileView { - path: `${Quickshell.env("HOME")}/.cache/wal/udt-palette.qml` - watchChanges: true - onFileChanged: reload() - onLoaded: { - const pick = key => { - const m = text().match(new RegExp(`property color ${key}: "(#[0-9a-fA-F]{6})"`)); - return m ? m[1] : null; - }; - root.base = pick("base") ?? root.base; - root.surface = pick("surface0") ?? root.surface; - root.text = pick("text") ?? root.text; - root.subtext = pick("subtext0") ?? root.subtext; - root.red = pick("red") ?? root.red; - root.green = pick("green") ?? root.green; - root.yellow = pick("yellow") ?? root.yellow; - root.surfaceAlt = pick("surface1") ?? root.surfaceAlt; - root.overlay = pick("overlay0") ?? root.overlay; - root.accent = pick("accent") ?? root.accent; - } - } -} diff --git a/mail-overview/Theme.qml b/mail-overview/Theme.qml new file mode 120000 index 0000000..3d2e40f --- /dev/null +++ b/mail-overview/Theme.qml @@ -0,0 +1 @@ +../shared/Theme.qml \ No newline at end of file diff --git a/shared/Theme.qml b/shared/Theme.qml new file mode 100644 index 0000000..423dd49 --- /dev/null +++ b/shared/Theme.qml @@ -0,0 +1,66 @@ +// Copyright (C) 2026 Danilo M. +// +// 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 Quickshell.Io +import QtQuick + +// The palette comes from unified-desktop-theme: udt-accent writes +// ~/.cache/wal/udt-palette.qml on every wallpaper change, holding the +// Macchiato colours from its palette.rasi plus the accent snapped from the +// wallpaper. Watching that file is what makes a theme edit show up here. +// +// The defaults below are only what renders before the file is read, or on a +// machine where unified-desktop-theme is not installed. +Singleton { + id: root + + property color base: "#24273a" + property color surface: "#363a4f" + property color text: "#cad3f5" + property color subtext: "#a5adcb" + property color red: "#ed8796" + property color green: "#a6da95" + property color yellow: "#eed49f" + property color surfaceAlt: "#494d64" + property color overlay: "#6e738d" + property color accent: "#b7bdf8" + + readonly property string fontFamily: "Noto Sans" + readonly property int fontSize: 16 + + // Parsed rather than imported: a generated file cannot be a QML import + // without a qmldir next to it, and the cache directory has no reason to + // carry one. The format is fixed and machine-written, so a regex is enough. + FileView { + path: `${Quickshell.env("HOME")}/.cache/wal/udt-palette.qml` + watchChanges: true + onFileChanged: reload() + onLoaded: { + const pick = key => { + const m = text().match(new RegExp(`property color ${key}: "(#[0-9a-fA-F]{6})"`)); + return m ? m[1] : null; + }; + root.base = pick("base") ?? root.base; + root.surface = pick("surface0") ?? root.surface; + root.text = pick("text") ?? root.text; + root.subtext = pick("subtext0") ?? root.subtext; + root.red = pick("red") ?? root.red; + root.green = pick("green") ?? root.green; + root.yellow = pick("yellow") ?? root.yellow; + root.surfaceAlt = pick("surface1") ?? root.surfaceAlt; + root.overlay = pick("overlay0") ?? root.overlay; + root.accent = pick("accent") ?? root.accent; + } + } +} diff --git a/vm-manager/Theme.qml b/vm-manager/Theme.qml deleted file mode 100644 index bddfe7d..0000000 --- a/vm-manager/Theme.qml +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (C) 2026 Danilo M. -// -// 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 Quickshell.Io -import QtQuick - -// The palette comes from unified-desktop-theme: udt-accent writes -// ~/.cache/wal/udt-palette.qml on every wallpaper change, holding the -// Macchiato colours from its palette.rasi plus the accent snapped from the -// wallpaper. Watching that file is what makes a theme edit show up here. -// -// The defaults below are only what renders before the file is read, or on a -// machine where unified-desktop-theme is not installed. -Singleton { - id: root - - property color base: "#24273a" - property color surface: "#363a4f" - property color text: "#cad3f5" - property color subtext: "#a5adcb" - property color red: "#ed8796" - property color green: "#a6da95" - property color yellow: "#eed49f" - property color overlay: "#6e738d" - property color accent: "#b7bdf8" - - readonly property string fontFamily: "Noto Sans" - readonly property int fontSize: 16 - - // Parsed rather than imported: a generated file cannot be a QML import - // without a qmldir next to it, and the cache directory has no reason to - // carry one. The format is fixed and machine-written, so a regex is enough. - FileView { - path: `${Quickshell.env("HOME")}/.cache/wal/udt-palette.qml` - watchChanges: true - onFileChanged: reload() - onLoaded: { - const pick = key => { - const m = text().match(new RegExp(`property color ${key}: "(#[0-9a-fA-F]{6})"`)); - return m ? m[1] : null; - }; - root.base = pick("base") ?? root.base; - root.surface = pick("surface0") ?? root.surface; - root.text = pick("text") ?? root.text; - root.subtext = pick("subtext0") ?? root.subtext; - root.red = pick("red") ?? root.red; - root.green = pick("green") ?? root.green; - root.yellow = pick("yellow") ?? root.yellow; - root.overlay = pick("overlay0") ?? root.overlay; - root.accent = pick("accent") ?? root.accent; - } - } -} diff --git a/vm-manager/Theme.qml b/vm-manager/Theme.qml new file mode 120000 index 0000000..3d2e40f --- /dev/null +++ b/vm-manager/Theme.qml @@ -0,0 +1 @@ +../shared/Theme.qml \ No newline at end of file diff --git a/volume-osd/Theme.qml b/volume-osd/Theme.qml deleted file mode 100644 index bee17b4..0000000 --- a/volume-osd/Theme.qml +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (C) 2026 Danilo M. -// -// 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 Quickshell.Io -import QtQuick - -// The palette comes from unified-desktop-theme: udt-accent writes -// ~/.cache/wal/udt-palette.qml on every wallpaper change, holding the -// Macchiato colours from its palette.rasi plus the accent snapped from the -// wallpaper. Watching that file is what makes a theme edit show up here. -// -// The defaults below are only what renders before the file is read, or on a -// machine where unified-desktop-theme is not installed. -Singleton { - id: root - - property color base: "#24273a" - property color surface: "#363a4f" - property color text: "#cad3f5" - property color subtext: "#a5adcb" - property color red: "#ed8796" - property color overlay: "#6e738d" - property color accent: "#b7bdf8" - - readonly property string fontFamily: "Noto Sans" - readonly property int fontSize: 16 - - // Parsed rather than imported: a generated file cannot be a QML import - // without a qmldir next to it, and the cache directory has no reason to - // carry one. The format is fixed and machine-written, so a regex is enough. - FileView { - path: `${Quickshell.env("HOME")}/.cache/wal/udt-palette.qml` - watchChanges: true - onFileChanged: reload() - onLoaded: { - const pick = key => { - const m = text().match(new RegExp(`property color ${key}: "(#[0-9a-fA-F]{6})"`)); - return m ? m[1] : null; - }; - root.base = pick("base") ?? root.base; - root.surface = pick("surface0") ?? root.surface; - root.text = pick("text") ?? root.text; - root.subtext = pick("subtext0") ?? root.subtext; - root.red = pick("red") ?? root.red; - root.overlay = pick("overlay0") ?? root.overlay; - root.accent = pick("accent") ?? root.accent; - } - } -} diff --git a/volume-osd/Theme.qml b/volume-osd/Theme.qml new file mode 120000 index 0000000..3d2e40f --- /dev/null +++ b/volume-osd/Theme.qml @@ -0,0 +1 @@ +../shared/Theme.qml \ No newline at end of file -- cgit v1.2.3