aboutsummaryrefslogtreecommitdiffstats
path: root/volume-osd/Theme.qml
diff options
context:
space:
mode:
Diffstat (limited to 'volume-osd/Theme.qml')
-rw-r--r--volume-osd/Theme.qml38
1 files changed, 26 insertions, 12 deletions
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;
}
}
}