So, i’m on hyprland and right now i’ve setup

exec-once = zsh -c ‘sleep 1’ && ps aux | rg ’ [w]aybar’ || while pgrep -f Hyprland > /dev/null ; do (waybar); done

what i need is to add a clause that terminates the “while true; do (waybar); done” that way when the compositor is restarted it kills the previous instance of while true do waybar

Just to break down the reasoning for my current command,

sleep 1 is to prevent certain stupid bugs from occurring that might be fixed now but weren’t in the early days

ps aux part is to make sure waybar isn’t already running

while pgrep -f Hyprland is SUPPOSED to end the loop when Hyprland ends, but it does not. I don’t know why.

The reason for the while loop is to restart waybar if it crashes, but right now, when i restart hyprland (I use wl-restart) the previous while loop doesn’t actually close, and waybar binds to the previous hyprlands IPC and I end up with no workspace icons or window names. Any ideas for making this work?