diff options
Diffstat (limited to 'config/hypr/scripts/WaybarCava.sh')
| -rwxr-xr-x | config/hypr/scripts/WaybarCava.sh | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/config/hypr/scripts/WaybarCava.sh b/config/hypr/scripts/WaybarCava.sh index 3305bb67..98db60dd 100755 --- a/config/hypr/scripts/WaybarCava.sh +++ b/config/hypr/scripts/WaybarCava.sh @@ -10,6 +10,9 @@ if ! command -v cava >/dev/null 2>&1; then exit 1 fi +# Proactively reap any stale Waybar-spawned cava (unique temp conf names) +pkill -f 'waybar-cava\..*\.conf' 2>/dev/null || true + # 0..7 → ▁▂▃▄▅▆▇█ bar="▁▂▃▄▅▆▇█" dict="s/;//g" @@ -32,7 +35,11 @@ printf '%d' $$ >"$pidfile" # Unique temp config + cleanup on exit config_file="$(mktemp "$RUNTIME_DIR/waybar-cava.XXXXXX.conf")" -cleanup() { rm -f "$config_file" "$pidfile"; } +cleanup() { + # Kill children (cava, sed) of this script, then remove files + pkill -P "$$" 2>/dev/null || true + rm -f "$config_file" "$pidfile" +} trap cleanup EXIT INT TERM cat >"$config_file" <<EOF @@ -52,4 +59,5 @@ ascii_max_range = 7 EOF # Stream cava output and translate digits 0..7 to bar glyphs -exec cava -p "$config_file" | sed -u "$dict" +# (no exec: keep this shell as the parent so the trap can reap children) +cava -p "$config_file" | sed -u "$dict" |
