diff options
Diffstat (limited to 'bin/udt-accent')
| -rwxr-xr-x | bin/udt-accent | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/bin/udt-accent b/bin/udt-accent index a862ae9..6462aae 100755 --- a/bin/udt-accent +++ b/bin/udt-accent @@ -34,6 +34,9 @@ MIN_CHROMA = 10.0 CACHE = Path.home() / ".cache" / "udt" OUTPUT = CACHE / "udt-accent.rasi" BORDER_OUTPUT = CACHE / "udt-border.lua" +# hyprlock cannot read the Lua border table, so the same three hues are also +# written as a hyprlang variable the lock config sources. See write_hyprlock. +HYPRLOCK_BORDER_OUTPUT = CACHE / "hyprlock-border.conf" SUBLIME = (Path.home() / ".config" / "sublime-text" / "Packages" / "User" / "udt.sublime-color-scheme") QML_OUTPUT = CACHE / "udt-palette.qml" @@ -208,6 +211,28 @@ def write_border(name): write_atomic(BORDER_OUTPUT, content) +def hyprlock_border_content(name): + """The hyprlock border gradient, as a hyprlang variable assignment. + + The lock panel, its avatar ring and the password outline all take this + gradient: the same three hues the Hyprland window border rotates through, + so a wallpaper change recolours the lock with the rest of the desktop. + One `rgb(hex) rgb(hex) rgb(hex) <angle>` line, which is the syntax the + input-field already used before it followed the theme. + """ + before, after = hue_neighbours(name) + stops = " ".join(f"rgb({ACCENTS[n].lstrip('#')})" for n in (before, name, after)) + return ( + "# Generated by udt-accent. Do not edit.\n" + f"$border = {stops} 45deg\n" + ) + + +def write_hyprlock_border(name): + """Write the hyprlock border gradient, atomically.""" + write_atomic(HYPRLOCK_BORDER_OUTPUT, hyprlock_border_content(name)) + + def read_palette(): """Parse palette.rasi into {name: "#rrggbb"}. @@ -429,6 +454,7 @@ def main(image): write_accent(name) write_border(name) + write_hyprlock_border(name) write_qml(name) write_sublime(name) write_sddm(name, image) @@ -485,6 +511,15 @@ def selftest(): delta = abs(_hue(ACCENTS[neighbour]) - _hue(ACCENTS[name])) assert min(delta, 2 * math.pi - delta) < math.pi, (name, neighbour) + # The lock border carries the same three hues as the window border, in + # hyprlang gradient syntax: three rgb() stops and an angle. Get it wrong and + # the panel border, avatar ring and password outline all draw hyprlock's + # default cyan instead of the accent. + lock = hyprlock_border_content(FALLBACK) + assert lock.count("rgb(") == 3, lock + assert lock.rstrip().endswith("45deg"), lock + assert "$border = " in lock, lock + # The SDDM theme reads this file through a symlink, so it has to carry every # key the theme asks for. The names are spelled out here rather than read # from SDDM_KEYS: deriving both the input and the check from the same |
