From 987933aa655e9c93191c1c0b2ee712813b6874ad Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Wed, 16 Sep 2026 09:19:49 +0200 Subject: 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 --- .gitignore | 4 ++++ bin/udt-palette | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/.gitignore b/.gitignore index c9b7fbb..18b6ecf 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,10 @@ __pycache__/ /templates/kvantum/theme.kvconfig /templates/kvantum/theme.svg /templates/obsidian/udt.css +/templates/gtk/gtk3.css +/templates/gtk/gtk4.css +/templates/gtk/index.theme +/templates/gtk/assets/*.svg /templates/typora/udt.css /templates/homepage/custom.css /templates/sublime/udt.sublime-color-scheme 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")) ] -- cgit v1.2.3