aboutsummaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/udt-palette49
1 files changed, 43 insertions, 6 deletions
diff --git a/bin/udt-palette b/bin/udt-palette
index 1a1c6b0..1df0c4f 100755
--- a/bin/udt-palette
+++ b/bin/udt-palette
@@ -114,17 +114,34 @@ def rgba(c):
BANNER = "Generated by udt-palette from palette/{scheme}.conf. Do not edit."
+# The names the rofi themes reference. They are Catppuccin spellings because
+# that is what the themes were written against, but each is filled from a role,
+# so a scheme that names nothing "base" still produces a parseable palette.
+ROFI_NAMES = [
+ ("base", "bg"), ("mantle", "bg_alt"), ("crust", "bg_deep"),
+ ("surface0", "surface"), ("surface1", "surface_alt"),
+ ("surface2", "surface_high"),
+ ("text", "fg"), ("subtext0", "fg_dim"), ("subtext1", "fg_bright"),
+ ("overlay0", "fg_faint"), ("overlay1", "mid_low"), ("overlay2", "mid_high"),
+ ("red", "critical"), ("green", "success"), ("yellow", "warning"),
+ ("teal", "info"), ("blue", "border_active"), ("lavender", "accent"),
+]
+
+
def gen_rofi(res, scheme, palette):
- """rofi: the structural palette, under the scheme's own colour names.
+ """rofi: the structural palette, under the names the themes reference.
- Emits palette names rather than roles because the rofi themes were written
- against Catppuccin names and still use them. The role layer reaches rofi
- through accent.rasi, which udt-accent generates per wallpaper.
+ Every value comes from a role, not from the scheme's own colour names: the
+ themes ask for @base and @text, and Tokyo Night calls those bg and fg, so
+ emitting palette names outright left the themes referencing colours that
+ did not exist and rofi refusing to parse the file.
"""
- rows = "\n".join(f" {k + ':':11}{v}ff;" for k, v in sorted(palette.items()))
+ rows = "\n".join(f" {name + ':':11}{hex8(res[role])};"
+ for name, role in ROFI_NAMES)
return (
f"/*\n * {BANNER.format(scheme=scheme)}\n *\n"
- " * Structural colors only. The accent lives in accent.rasi.\n */\n\n"
+ " * Structural colors only. The accent lives in accent.rasi.\n"
+ " * Names are Catppuccin's; values come from the scheme's roles.\n */\n\n"
f"* {{\n{rows}\n}}\n"
)
@@ -444,6 +461,26 @@ def selftest():
assert not missing, f"{scheme} is missing roles: {sorted(missing)}"
assert not extra, f"{scheme} has roles no other scheme has: {sorted(extra)}"
+ # Every name the rofi themes reference must be emitted, or rofi refuses to
+ # parse the theme and every launcher on the desktop stops opening. This is
+ # a real regression that shipped: gen_rofi used to emit the scheme's own
+ # colour names, which only happened to match under Catppuccin.
+ theme_dir = REPO / "rofi" / "udt"
+ used = set()
+ for theme in theme_dir.glob("*.rasi"):
+ if theme.name in ("palette.rasi", "accent.rasi"):
+ continue
+ # Only @name in a colour-property value: @import is a directive and
+ # @radius a dimension, neither of which this file defines.
+ # Only @name in a colour-property value. @import is a directive and
+ # border-radius a dimension, so neither is a colour this file owes.
+ used |= set(re.findall(
+ r"(?!border-radius)(?:[\w-]*color|background[\w-]*|border):\s*@(\w+)",
+ theme.read_text()))
+ emitted = {name for name, _ in ROFI_NAMES} | {"accent"}
+ missing = used - emitted
+ assert not missing, f"rofi themes reference undefined colours: {sorted(missing)}"
+
# Alpha survives the round trip into each syntax.
assert hex8((202, 211, 245, 75)) == "#cad3f5bf", hex8((202, 211, 245, 75))
assert hex8((202, 211, 245, 100)) == "#cad3f5ff"