diff options
Diffstat (limited to 'bin/udt-palette')
| -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")) ] |
