forge
Explore
Log in

Don't you dare go Hollow

Make the wallust border gradient actually track the wallpaper

Browse files at this commit

3eb761e5e180df1b6559bacb616a2abdfa7fd59aAhmet Kaan GümüşParent: d068d19
  • fix
    • make the wallust border gradient actually track the wallpaper
Show full message
fix(niri): make the wallust border gradient actually track the wallpaper

The hook read ~/.cache/wallust/sequences, but the picker runs
`wallust run -qs` and -s skips writing that file — so it froze at whatever
palette was current when it was last written, and the border silently
re-applied stale colors on every wallpaper change. Colors now come from a
wallust template, which regenerates on every run.

~/.config/wallust uses per-file symlinks rather than a directory symlink, so
the new template also needs one in ~/.config/wallust/templates/ to be visible
to wallust at all.

Also:
- draw the border AROUND windows (draw-border-with-background false). niri
  uses the border as the window background by default, which is invisible
  behind an opaque window, so the border never showed up.
- geometry-corner-radius 12 + clip-to-geometry, so the border follows the
  rounded corners GTK4/libadwaita apps draw for themselves.
- interpolate in "oklch" instead of "oklch longer hue". The long arc walked
  290 degrees around the hue wheel and put blue, cyan and green in the middle
  of a pink-to-gold gradient.

Note: fullscreen windows have no border at all, and unfocused ones show only
the flat inactive color.
.config/niri/config.kdlmodified+16 -1
@@ -232,7 +232,7 @@ layout {
232232 // colors cannot live in a separate generated file. Keep the marker
233233 // comment directly above it, and keep the whole thing on one line.
234234 // WALLUST-GRADIENT
235- active-gradient from="#7B6753" to="#BC7857" angle=90 in="oklch longer hue"
235+ active-gradient from="#035233" to="#78818A" angle=90 in="oklch"
236236
237237 // Hyprland col.inactive_border = rgba(595959aa)
238238 inactive-color "#595959aa"
@@ -364,6 +364,21 @@ animations {
364364 // Find more information on the wiki:
365365 // https://niri-wm.github.io/niri/Configuration:-Window-Rules
366366
367+// Draw the border AROUND windows instead of behind them. By default niri uses
368+// the border as the window background, which is invisible behind an opaque
369+// window — so the Hyprland-style border simply never showed up. This is the
370+// same setting that stopped the gradient bleeding through wezterm's opacity.
371+window-rule {
372+ draw-border-with-background false
373+
374+ // GTK4/libadwaita apps (nautilus, ...) round their own corners at ~12px,
375+ // while niri draws the border square — the two did not line up. Telling
376+ // niri the radius makes the border follow the curve, and clip-to-geometry
377+ // trims the window to it so nothing pokes out past the border.
378+ geometry-corner-radius 12
379+ clip-to-geometry true
380+}
381+
367382 window-rule {
368383 // This regular expression is intentionally made as specific as possible,
369384 // since this is the default config, and we want no false positives.
.config/scripts/niri/wallust_niri_colors.shmodified+14 -9
@@ -15,19 +15,24 @@
1515 set -euo pipefail
1616
1717 CONFIG="$HOME/.config/niri/config.kdl"
18-SEQUENCES="$HOME/.cache/wallust/sequences"
18+# Written by the 'niri' entry in wallust.toml [templates] from
19+# ~/.config/wallust/templates/niri-colors.sh. Do NOT read
20+# ~/.cache/wallust/sequences instead: the picker runs `wallust run -qs`, and -s
21+# skips writing that file, so it silently goes stale and the border never
22+# changes.
23+COLORS="$HOME/.cache/wallust/niri-colors.sh"
1924 MARKER="// WALLUST-GRADIENT"
2025
2126 [ -f "$CONFIG" ] || exit 0
22-[ -f "$SEQUENCES" ] || exit 0
27+[ -f "$COLORS" ] || exit 0
2328
24-# wallust writes the palette as terminal OSC sequences: ]4;<n>;#RRGGBB
25-color_at() {
26- grep -oP "\]4;$1;#\K[0-9A-Fa-f]{6}" "$SEQUENCES" | head -1
27-}
29+# shellcheck source=/dev/null
30+. "$COLORS"
2831
29-FROM=$(color_at 4)
30-TO=$(color_at 6)
32+# wallust's {{colorN}} placeholders already carry the leading '#'; strip it so
33+# exactly one is added back below regardless of format.
34+FROM="${NIRI_BORDER_FROM#\#}"
35+TO="${NIRI_BORDER_TO#\#}"
3136
3237 if [ -z "$FROM" ] || [ -z "$TO" ]; then
3338 exit 0
@@ -40,7 +45,7 @@ awk -v marker="$MARKER" -v from="#$FROM" -v to="#$TO" '
4045 hit {
4146 match($0, /^[ \t]*/)
4247 indent = substr($0, 1, RLENGTH)
43- printf "%sactive-gradient from=\"%s\" to=\"%s\" angle=90 in=\"oklch longer hue\"\n", indent, from, to
48+ printf "%sactive-gradient from=\"%s\" to=\"%s\" angle=90 in=\"oklch\"\n", indent, from, to
4449 hit = 0
4550 next
4651 }
.config/wallust/templates/niri-colors.shadded+5 -0
@@ -0,0 +1,5 @@
1+# Generated by wallust — consumed by ~/.config/scripts/niri/wallust_niri_colors.sh
2+# Do not read ~/.cache/wallust/sequences instead: the wallpaper picker runs
3+# `wallust run -qs`, and -s skips writing that file, so it goes stale.
4+NIRI_BORDER_FROM="{{color4}}"
5+NIRI_BORDER_TO="{{color6}}"
.config/wallust/wallust.tomlmodified+1 -0
@@ -56,6 +56,7 @@ gtk2 = { template = 'gtk2.gtkrc', target = '~/.gtkrc-2.0.mine' }
5656 kdeglobals = { template = 'kdeglobals', target = '~/.config/kdeglobals' }
5757 qt5ct = { template = 'qt5ct-wallust.conf', target = '~/.config/qt5ct/colors/wallust.conf' }
5858 qt6ct = { template = 'qt6ct-wallust.conf', target = '~/.config/qt6ct/colors/wallust.conf' }
59+niri = { template = 'niri-colors.sh', target = '~/.cache/wallust/niri-colors.sh' }
5960 [hooks]
6061 # Resolve mix() and compute surface colors for GTK and QT
6162 theme_colors = """~/.config/scripts/shared/theme_colors.sh"""