diff options
| author | Danilo M. <danix@danix.xyz> | 2026-09-16 09:19:49 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-09-16 09:19:49 +0200 |
| commit | 987933aa655e9c93191c1c0b2ee712813b6874ad (patch) | |
| tree | 52388dba96371c0eb6ed74ecdbcfbfa771b0e9fc /bin | |
| parent | 0bc440f837977ea0164d9899a33458c995f1412d (diff) | |
| download | unified-desktop-theme-987933aa655e9c93191c1c0b2ee712813b6874ad.tar.gz unified-desktop-theme-987933aa655e9c93191c1c0b2ee712813b6874ad.zip | |
feat(palette): add GTK3 and GTK4 as palette consumers
70 new targets: the two stylesheets, the metatheme descriptor and 67 widget
assets. The assets are discovered from disk rather than listed, because they
arrive as a set from upstream and a hand-written list would miss one added by
a future refresh.
Substitution does the _RGB@ form before the bare @ROLE@: @FG@ is a prefix of
@FG_RGB@, so the other order would eat the start of the triple placeholder
and leave a literal "_RGB@" in the CSS.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Diffstat (limited to 'bin')
| -rwxr-xr-x | bin/udt-palette | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/bin/udt-palette b/bin/udt-palette index f92a6b7..bee7dc5 100755 --- a/bin/udt-palette +++ b/bin/udt-palette @@ -368,6 +368,37 @@ def gen_kvantum(res, scheme, palette, template): return out +def gen_gtk(res, scheme, palette, template): + """GTK3/GTK4: substitute the palette into the upstream stylesheet. + + Derived from catppuccin/gtk v1.0.3, which is archived upstream. The whole + file is substituted rather than just its @define-color block, because the + 8400 lines above that block hardcode palette colours too. + + Two forms per role: the hex, and the bare `r, g, b` triple that the theme + writes inside rgba(). Neutral greys and upstream's derived tints are left + exactly as drawn, the same rule the Kvantum SVG follows. + """ + out = template + for role in GTK_ROLES: + # _RGB@ first: @FG@ is a prefix of @FG_RGB@, so the bare form would + # otherwise eat the start of the triple placeholder and leave "_RGB@". + out = out.replace(f"@{role.upper()}_RGB@", rgb_triple(res[role])) + out = out.replace(f"@{role.upper()}@", hex6(res[role])) + # Spelled for the upstream colour it replaces rather than for its role, + # which keeps the template readable against the theme it came from. + out = out.replace("@MAUVE@", hex6(res["highlight"])) + return out + + +def gen_gtk_asset(res, scheme, palette, template): + """One GTK widget asset. Only three palette colours appear in the SVGs.""" + out = template + for role in ("bg", "bg_alt", "accent"): + out = out.replace(f"@{role.upper()}@", hex6(res[role])) + return out + + def gen_homepage(res, scheme, palette): """gethomepage: a custom.css overriding its ten-step colour ramp. @@ -595,6 +626,18 @@ TARGETS = [ "templates/sublime/udt.sublime-color-scheme.in"), ("templates/sublime/udt.sublime-theme", gen_sublime_theme, "templates/sublime/udt.sublime-theme.in"), + ("templates/gtk/gtk3.css", gen_gtk, "templates/gtk/gtk3.css.in"), + ("templates/gtk/gtk4.css", gen_gtk, "templates/gtk/gtk4.css.in"), + ("templates/gtk/index.theme", gen_gtk, "templates/gtk/index.theme.in"), +] + +# The GTK widget assets, one target each. Discovered rather than listed: there +# are 67 of them and they arrive as a set from upstream, so a hand-written list +# would silently miss one added by a future theme refresh. +TARGETS += [ + (f"templates/gtk/assets/{p.name[:-3]}", gen_gtk_asset, + f"templates/gtk/assets/{p.name}") + for p in sorted((REPO / "templates" / "gtk" / "assets").glob("*.svg.in")) ] |
