diff options
| author | Danilo M. <danix@danix.xyz> | 2026-09-11 17:20:50 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-09-11 17:20:50 +0200 |
| commit | 7b55910a786c7652ac80a576399ebd9f81a8ac72 (patch) | |
| tree | 4adaedb0f0ac5003ecc0e19093a2cb5871b18deb /bin/udt-accent | |
| parent | c7cb9dad4e782ee0ff99773c3607ec3b7792c723 (diff) | |
| download | unified-desktop-theme-7b55910a786c7652ac80a576399ebd9f81a8ac72.tar.gz unified-desktop-theme-7b55910a786c7652ac80a576399ebd9f81a8ac72.zip | |
feat(palette): generate every themed config from one scheme
Colours were written down five times: rofi's palette.rasi, the waybar theme,
the kitty theme, the conky and dunst templates, and a MACCHIATO dict inside
udt-accent. Changing scheme meant finding all five, and they had already
drifted: the active waybar theme was Macchiato while theme.css next to it was
Mocha, and nothing imported the latter.
Now a scheme is two files. palette/<scheme>.conf holds the colours under the
scheme's own names, and palette/roles-<scheme>.conf says what each is for.
palette/roles.conf is one `scheme =` line selecting the pair. bin/udt-palette
renders that into each consumer's syntax and install.sh runs it first.
The role map is per-scheme rather than shared because the palettes are
genuinely different shapes: Nord has no `base`, Dracula no `surface0`, and
forcing Catppuccin's names onto them would have meant either renaming their
colours or inventing values. A role names a palette colour with two optional
modifiers, `name/75` for alpha and `name*50` for brightness. The second exists
because GTK's shade() has no palette name to point at.
Ships macchiato, tokyo-night, nord and dracula. --selftest resolves every role
in every scheme and asserts they define the same set, so a scheme that cannot
satisfy a consumer fails at install rather than when someone switches to it.
Verified against the live configs: all 46 waybar colours resolve identically to
the previously active theme including its alpha() and shade() derivations, the
kitty theme is colour-for-colour identical, and the rofi palette has the same
26 values. Generated files are gitignored; switching scheme and switching back
reproduces the originals.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015gbjA2bmswN8jyPDKzrvqe
Diffstat (limited to 'bin/udt-accent')
| -rwxr-xr-x | bin/udt-accent | 49 |
1 files changed, 12 insertions, 37 deletions
diff --git a/bin/udt-accent b/bin/udt-accent index 7949597..1a222b5 100755 --- a/bin/udt-accent +++ b/bin/udt-accent @@ -21,25 +21,12 @@ import sys import tempfile from pathlib import Path -# The candidate accents. rosewater and flamingo are excluded as near-neutral -# tints that capture saturated inputs, and maroon and sapphire as near-duplicate -# hues of red and sky. lavender sits close to mauve but is kept: it is the -# desktop-wide fallback, used by Qt, GTK and anything else that needs one fixed -# accent, so it has to be a value snap() can also return. -ACCENTS = { - "pink": "#f5bde6", - "mauve": "#c6a0f6", - "lavender": "#b7bdf8", - "red": "#ed8796", - "peach": "#f5a97f", - "yellow": "#eed49f", - "green": "#a6da95", - "teal": "#8bd5ca", - "sky": "#91d7e3", - "blue": "#8aadf4", -} - -FALLBACK = "lavender" +# The colour tables are generated: udt-palette renders them from +# palette/<scheme>.conf and palette/roles-<scheme>.conf, so the accents this +# snaps to follow whatever scheme is selected. Regenerate with ./install.sh. +sys.path.insert(0, str(Path(__file__).resolve().parent)) +from udt_colors import ACCENTS, FALLBACK, PALETTE # noqa: E402 + MIN_CHROMA = 10.0 OUTPUT = Path.home() / ".cache" / "wal" / "udt-accent.rasi" @@ -47,24 +34,12 @@ BORDER_OUTPUT = Path.home() / ".cache" / "wal" / "udt-border.lua" DUNSTRC = Path.home() / ".cache" / "wal" / "dunstrc" QML_OUTPUT = Path.home() / ".cache" / "wal" / "udt-palette.qml" -# The installed palette, which is a symlink back into this repo. Read rather -# than duplicated: palette.rasi is the one place the structural colours are -# written down, and a second copy here would drift the first time one changed. +# The installed rofi palette, itself generated by udt-palette. Read rather than +# duplicated so the QML singleton carries exactly the colours rofi uses, under +# the same names. PALETTE_RASI = Path.home() / ".config" / "rofi" / "udt" / "palette.rasi" COLORS_JSON = Path.home() / ".cache" / "wal" / "colors.json" -# Catppuccin Macchiato, in pywal's slot order. Firefox is themed from this -# via pywalfox, which reads colors.json and nothing else. -MACCHIATO = { - "background": "#24273a", "foreground": "#cad3f5", "cursor": "#f4dbd6", - "colors": [ - "#494d64", "#ed8796", "#a6da95", "#eed49f", - "#8aadf4", "#f5bde6", "#8bd5ca", "#b8c0e0", - "#5b6078", "#ed8796", "#a6da95", "#eed49f", - "#8aadf4", "#f5bde6", "#8bd5ca", "#a5adcb", - ], -} - def write_atomic(path, content): """Write a file atomically, so no reader ever sees it half-written. @@ -256,7 +231,7 @@ def write_colors_json(name, image): palette stays fixed Macchiato while only the accent moves. """ hexval = ACCENTS[name] - colors = list(MACCHIATO["colors"]) + colors = list(PALETTE["colors"]) # Slots 4 and 12 are pywalfox's link/highlight colour. colors[4] = colors[12] = hexval @@ -267,8 +242,8 @@ def write_colors_json(name, image): "wallpaper": os.path.realpath(image), "alpha": "100", "special": { - "background": MACCHIATO["background"], - "foreground": MACCHIATO["foreground"], + "background": PALETTE["background"], + "foreground": PALETTE["foreground"], "cursor": hexval, }, "colors": {f"color{i}": c for i, c in enumerate(colors)}, |
