aboutsummaryrefslogtreecommitdiffstats
path: root/bin/udt-palette
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-09-16 09:30:19 +0200
committerDanilo M. <danix@danix.xyz>2026-09-16 09:30:19 +0200
commita366de437867f29ffd58673f6d1b6359135e1cad (patch)
tree316857551e81803cd7cb138ffbdf1cb5315ca877 /bin/udt-palette
parent82dfcae2225e4313f400e87e97b1e5f42a0e7b3f (diff)
downloadunified-desktop-theme-a366de437867f29ffd58673f6d1b6359135e1cad.tar.gz
unified-desktop-theme-a366de437867f29ffd58673f6d1b6359135e1cad.zip
fix(gtk): derive the twelve computed tints from the palette too
Twelve hexes were shades upstream computed from a palette colour rather than taking one. They were left literal on the same reasoning as the neutral greys, which was wrong: a grey is shading, but each of these paints one widget surface in a colour that is supposed to be the theme's. Under any scheme but Macchiato they stayed Macchiato, including the window close, minimise and maximise hover fills. They are substituted as @ROLE_PCT@ now, the percentage being that shade's brightness relative to its base. shade() scales each channel and clamps, so it keeps the relationship rather than the exact upstream value; closest on the accent family, crudest on the reds, where upstream darkened toward saturation. GTK4 carries ten of the twelve: the selected progress bar and the selection-mode titlebar backdrop are GTK3-only widgets upstream. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Diffstat (limited to 'bin/udt-palette')
-rwxr-xr-xbin/udt-palette37
1 files changed, 37 insertions, 0 deletions
diff --git a/bin/udt-palette b/bin/udt-palette
index a9aa005..95b9092 100755
--- a/bin/udt-palette
+++ b/bin/udt-palette
@@ -368,6 +368,38 @@ def gen_kvantum(res, scheme, palette, template):
return out
+# Shades upstream computed from a palette colour rather than taking one. Each
+# paints exactly one widget surface, so leaving them literal (the rule that is
+# right for the neutral greys) left twelve lavender and Macchiato-tinted spots
+# on every other scheme: the window close/min/max hover fills among them.
+#
+# The percentage is that shade's brightness relative to its base, measured off
+# the Macchiato theme these were derived from. Reproducing the exact upstream
+# value is not the goal; keeping the relationship is.
+GTK_TINTS = [
+ ("@ACCENT_93@", "accent", 93),
+ ("@ACCENT_103@", "accent", 103),
+ ("@ACCENT_109@", "accent", 109),
+ ("@ACCENT_118@", "accent", 118),
+ ("@CRITICAL_110@", "critical", 110),
+ ("@CRITICAL_92@", "critical", 92),
+ ("@CRITICAL_79@", "critical", 79),
+ ("@WARNING_105@", "warning", 105),
+ ("@WARNING_94@", "warning", 94),
+ ("@WARNING_86@", "warning", 86),
+ ("@SUCCESS_109@", "success", 109),
+ ("@SUCCESS_81@", "success", 81),
+]
+
+
+def shade(c, pct):
+ """Scale a colour's channels by pct, clamped to 0-255."""
+ r, g, b, a = c
+ return (min(255, round(r * pct / 100)),
+ min(255, round(g * pct / 100)),
+ min(255, round(b * pct / 100)), a)
+
+
def gen_gtk(res, scheme, palette, template):
"""GTK3/GTK4: substitute the palette into the upstream stylesheet.
@@ -380,6 +412,10 @@ def gen_gtk(res, scheme, palette, template):
exactly as drawn, the same rule the Kvantum SVG follows.
"""
out = template
+ # Tints first: @ACCENT_93@ starts with @ACCENT, so the plain role loop
+ # below would otherwise replace that prefix and leave a stray "_93@".
+ for placeholder, role, pct in GTK_TINTS:
+ out = out.replace(placeholder, hex6(shade(res[role], pct)))
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@".
@@ -732,6 +768,7 @@ def selftest():
gtk_dir = REPO / "templates" / "gtk"
known = {f"@{r.upper()}@" for r in GTK_ROLES}
known |= {f"@{r.upper()}_RGB@" for r in GTK_ROLES}
+ known |= {placeholder for placeholder, _, _ in GTK_TINTS}
known.add("@MAUVE@")
for tpl in sorted(gtk_dir.glob("*.in")) + sorted((gtk_dir / "assets").glob("*.in")):
used = set(re.findall(r"@[A-Z][A-Z_]*@", tpl.read_text()))