From dab9cf5c175ad1f0fedcd4caa71e36fa80a1d8de Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Wed, 16 Sep 2026 09:17:58 +0200 Subject: feat(palette): add an rgb_triple helper and the GTK role list GTK's stylesheets write colours two ways: as a hex, and as a bare decimal triple inside rgba(). The existing rgba() helper emits without spaces and wraps the call itself, so neither form matches what the upstream theme contains; rgb_triple emits just `r, g, b` and the template keeps the call. Co-Authored-By: Claude Opus 5 --- bin/udt-palette | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'bin/udt-palette') diff --git a/bin/udt-palette b/bin/udt-palette index 09731de..f92a6b7 100755 --- a/bin/udt-palette +++ b/bin/udt-palette @@ -112,6 +112,17 @@ def rgb_array(c): return f"[{r}, {g}, {b}]" +def rgb_triple(c): + """`r, g, b` with spaces, which is how GTK's CSS writes an rgba() colour. + + The rgba() helper below emits without spaces and wraps in rgb()/rgba(), + neither of which matches what the upstream GTK theme contains, so the + substitution is on the bare triple and the template keeps the rgba() call. + """ + r, g, b, _ = c + return f"{r}, {g}, {b}" + + def rgba(c): r, g, b, a = c return f"rgb({r},{g},{b})" if a == 100 else f"rgba({r},{g},{b},{a / 100:.2f})" @@ -329,6 +340,12 @@ TYPORA_ROLES = ["bg", "bg_deep", "surface_alt", "fg", "fg_dim", "fg_faint", "info", "highlight"] +# The roles GTK's stylesheets reference. Both a hex and a decimal-triple form +# of each is substituted, because the upstream theme writes colours both ways. +GTK_ROLES = ["fg", "bg", "bg_alt", "bg_deep", "surface", "surface_alt", + "accent", "critical", "warning", "success", "highlight", "info", + "blue", "peach"] + KVANTUM_ROLES = ["bg", "bg_alt", "surface", "surface_alt", "surface_high", "fg", "fg_dim", "fg_faint", "mid_high", "accent", "accent_dim", "accent_bright", "highlight", "critical"] -- cgit v1.2.3