From af6f64aa1bc0b85bdc65d56dc8da1db7afd4c7b9 Mon Sep 17 00:00:00 2001 From: name Date: Sat, 31 Oct 2026 16:11:09 +0100 Subject: daco --- home-manager/scripts/matugen-sync.sh | 46 ++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) (limited to 'home-manager/scripts/matugen-sync.sh') diff --git a/home-manager/scripts/matugen-sync.sh b/home-manager/scripts/matugen-sync.sh index 4a469d9..a9119bf 100755 --- a/home-manager/scripts/matugen-sync.sh +++ b/home-manager/scripts/matugen-sync.sh @@ -4,6 +4,48 @@ # files like current_DP-2 or current_eDP-1. STATE_DIR="$HOME/.cache/serpantinum/wallpaper/" +reload_foot_live_colors() { + local colors_file="$HOME/.cache/matugen/foot-colors.ini" + local -A colors + local -A seen_tty + local key + local value + local tty_path + local pid + local seq="" + + [ -r "$colors_file" ] || return 0 + + while IFS='=' read -r key value; do + # Skip section headers and malformed lines. + [[ "$key" == "["* || -z "$key" || -z "$value" ]] && continue + key="${key//[[:space:]]/}" + value="${value%% *}" + value="${value//[[:space:]]/}" + [[ "$value" =~ ^[0-9A-Fa-f]{6}$ ]] || continue + colors["$key"]="#$value" + done < "$colors_file" + + [ -n "${colors[foreground]}" ] && seq+="\e]10;${colors[foreground]}\a" + [ -n "${colors[background]}" ] && seq+="\e]11;${colors[background]}\a" + [ -n "${colors[cursor]}" ] && seq+="\e]12;${colors[cursor]}\a" + + for i in 0 1 2 3 4 5 6 7; do + [ -n "${colors[regular$i]}" ] && seq+="\e]4;$i;${colors[regular$i]}\a" + [ -n "${colors[bright$i]}" ] && seq+="\e]4;$((i + 8));${colors[bright$i]}\a" + done + + [ -n "$seq" ] || return 0 + + for pid in $(pgrep -x foot 2>/dev/null) $(pgrep -x footclient 2>/dev/null); do + tty_path=$(readlink "/proc/$pid/fd/0" 2>/dev/null) || continue + [[ "$tty_path" == /dev/pts/* ]] || continue + [ -n "${seen_tty[$tty_path]}" ] && continue + printf '%b' "$seq" > "$tty_path" 2>/dev/null || true + seen_tty["$tty_path"]=1 + done +} + inotifywait -m -e close_write "$STATE_DIR" | while read -r directory events filename; do # Only react to monitor pointer files like current_DP-2, current_eDP-1, @@ -25,8 +67,8 @@ while read -r directory events filename; do # 2. Reload Hyprland hyprctl reload - # 3. Reload running Foot terminals - pkill -HUP foot + # 3. Live-apply colors in running Foot terminals. + reload_foot_live_colors fi done -- cgit v1.2.3