aboutsummaryrefslogtreecommitdiffstats
path: root/bin/udt-palette
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-09-16 09:17:58 +0200
committerDanilo M. <danix@danix.xyz>2026-09-16 09:17:58 +0200
commitdab9cf5c175ad1f0fedcd4caa71e36fa80a1d8de (patch)
treeeb18e4daec564edcbafe323fbaaff835aae4bdea /bin/udt-palette
parent2d476f522596e2d7e623ad687f0db76a67832bc7 (diff)
downloadunified-desktop-theme-dab9cf5c175ad1f0fedcd4caa71e36fa80a1d8de.tar.gz
unified-desktop-theme-dab9cf5c175ad1f0fedcd4caa71e36fa80a1d8de.zip
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 <noreply@anthropic.com>
Diffstat (limited to 'bin/udt-palette')
-rwxr-xr-xbin/udt-palette17
1 files changed, 17 insertions, 0 deletions
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"]