summaryrefslogtreecommitdiff
path: root/home-manager/scripts
diff options
context:
space:
mode:
authorname <[email protected]>2026-10-31 16:11:09 +0100
committername <[email protected]>2026-10-31 16:11:09 +0100
commitaf6f64aa1bc0b85bdc65d56dc8da1db7afd4c7b9 (patch)
treef37d34d0b663ca49d3b7b7c5c1f16cdf666a32c2 /home-manager/scripts
parent8f0d296c321854308d7e349ec0c76b95cfbbc797 (diff)
downloadnixos-af6f64aa1bc0b85bdc65d56dc8da1db7afd4c7b9.tar.xz
nixos-af6f64aa1bc0b85bdc65d56dc8da1db7afd4c7b9.zip
daco
Diffstat (limited to 'home-manager/scripts')
-rwxr-xr-xhome-manager/scripts/matugen-sync.sh46
1 files changed, 44 insertions, 2 deletions
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