aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-09-11 16:30:31 +0200
committerDanilo M. <danix@danix.xyz>2026-09-11 16:30:31 +0200
commit4f01824832da8455a40446dc2ee949545f470ec5 (patch)
tree3c40e8b5c19c2e912cbc7f218bc797cacb852847
parent1ffc9c8e8fd3b97f343d6e2360f030cb08b42a18 (diff)
downloadquickshell-4f01824832da8455a40446dc2ee949545f470ec5.tar.gz
quickshell-4f01824832da8455a40446dc2ee949545f470ec5.zip
refactor(theme): read the palette from unified-desktop-theme
Both components had their own copy of the Macchiato colours, and the second copy appeared the moment there was a second component. Editing the palette meant editing it in as many places as there were shells, and they would have drifted. They now read ~/.cache/wal/udt-palette.qml, which udt-accent generates from unified-desktop-theme's palette.rasi. The file is watched, so a palette change reaches a running shell in place, the same way the accent already did. What is left in Theme.qml is a fallback, used before the file has been read and on a machine where unified-desktop-theme is not installed, which is what keeps each directory runnable on its own. The file is parsed rather than imported: a generated QML singleton cannot be imported without a qmldir beside it, and the wal cache has no reason to carry one. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G7NRsGyF9jGfPYS4zPqpN7
-rw-r--r--vm-manager/README.md8
-rw-r--r--vm-manager/Theme.qml47
-rw-r--r--volume-osd/README.md14
-rw-r--r--volume-osd/Theme.qml38
4 files changed, 72 insertions, 35 deletions
diff --git a/vm-manager/README.md b/vm-manager/README.md
index e11b7f2..1bc20ef 100644
--- a/vm-manager/README.md
+++ b/vm-manager/README.md
@@ -82,9 +82,11 @@ nowhere to go: the process output is not attached to a terminal.
## Theme
-`Theme.qml` is the copy from `volume-osd` with three colours added for state
-dots (green running, yellow transitional, red crashed). The accent still comes
-from `~/.cache/wal/udt-accent.rasi` and still tracks the wallpaper.
+`Theme.qml` carries only fallbacks. The palette comes from
+`~/.cache/wal/udt-palette.qml`, generated by `udt-accent` from
+unified-desktop-theme's `palette.rasi`, and is watched: editing the palette
+there recolours a running drawer without restarting it. State dots use the
+green, yellow and red from that palette.
The frosting is Hyprland's, matched on this window's namespace:
diff --git a/vm-manager/Theme.qml b/vm-manager/Theme.qml
index 714e289..bddfe7d 100644
--- a/vm-manager/Theme.qml
+++ b/vm-manager/Theme.qml
@@ -15,33 +15,50 @@ 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
- // Catppuccin Macchiato. Fixed, same base as unified-desktop-theme.
- readonly property color base: "#24273a"
- readonly property color surface: "#363a4f"
- readonly property color text: "#cad3f5"
- readonly property color subtext: "#a5adcb"
- readonly property color red: "#ed8796"
- readonly property color green: "#a6da95"
- readonly property color yellow: "#eed49f"
- readonly property color overlay: "#6e738d"
-
- // Tracks the wallpaper, like rofi and dunst do. Lavender until read.
+ 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
- // udt-accent writes one line: `* { accent: #rrggbbaa; }`
+ // 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-accent.rasi`
+ path: `${Quickshell.env("HOME")}/.cache/wal/udt-palette.qml`
watchChanges: true
onFileChanged: reload()
onLoaded: {
- const m = text().match(/accent:\s*(#[0-9a-fA-F]{6})/);
- if (m) root.accent = m[1];
+ 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/volume-osd/README.md b/volume-osd/README.md
index 3ef0212..f651c1d 100644
--- a/volume-osd/README.md
+++ b/volume-osd/README.md
@@ -60,11 +60,15 @@ it just renders flat translucent instead of frosted.
## Theme
-`Theme.qml` holds the Catppuccin Macchiato palette. The accent is read from
-`~/.cache/wal/udt-accent.rasi`, the file `udt-accent` writes on every wallpaper
-change, and is watched, so the OSD recolours without a restart. Lavender
-(`#b7bdf8`) is the fallback when that file is absent, which is also what makes
-this directory runnable on a machine that has no unified-desktop-theme.
+`Theme.qml` holds no palette of its own beyond a fallback. The colours come
+from `~/.cache/wal/udt-palette.qml`, which `udt-accent` generates on every
+wallpaper change from unified-desktop-theme's `palette.rasi`, carrying the
+whole Macchiato palette plus the accent snapped from the wallpaper.
+
+That file is watched, so editing the palette in unified-desktop-theme and
+regenerating recolours a running OSD with no restart. Where the file does not
+exist, the hardcoded defaults in `Theme.qml` apply, which is what keeps this
+directory runnable on a machine without unified-desktop-theme.
## Two details worth knowing
diff --git a/volume-osd/Theme.qml b/volume-osd/Theme.qml
index 4b9af5c..21e6c1a 100644
--- a/volume-osd/Theme.qml
+++ b/volume-osd/Theme.qml
@@ -15,30 +15,44 @@ 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
- // Catppuccin Macchiato. Fixed, same base as unified-desktop-theme.
- readonly property color base: "#24273a"
- readonly property color surface: "#363a4f"
- readonly property color text: "#cad3f5"
- readonly property color subtext: "#a5adcb"
- readonly property color red: "#ed8796"
-
- // Tracks the wallpaper, like rofi and dunst do. Lavender until read.
+ property color base: "#24273a"
+ property color surface: "#363a4f"
+ property color text: "#cad3f5"
+ property color subtext: "#a5adcb"
+ property color red: "#ed8796"
property color accent: "#b7bdf8"
readonly property string fontFamily: "Noto Sans"
readonly property int fontSize: 16
- // udt-accent writes one line: `* { accent: #rrggbbaa; }`
+ // 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-accent.rasi`
+ path: `${Quickshell.env("HOME")}/.cache/wal/udt-palette.qml`
watchChanges: true
onFileChanged: reload()
onLoaded: {
- const m = text().match(/accent:\s*(#[0-9a-fA-F]{6})/);
- if (m) root.accent = m[1];
+ 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.accent = pick("accent") ?? root.accent;
}
}
}