#!/usr/bin/env bash# launch.sh — start one Polybar instance per connected monitor.# Called from bspwmrc. Safe to re-run (kills the old bars first).# terminate any running bars and wait for them to diepkill -x polybar
while pgrep -x polybar >/dev/null; do sleep 0.2; done# launch a bar on every connected output (handles Parallels multi-display).# The systray can only live on ONE bar — give it to the primary output and# hide it elsewhere, otherwise the non-owning bars fight over it and flicker.iftype xrandr >/dev/null 2>&1; thenprimary=$(xrandr --query | awk '/ primary/{print $1}')[ -n "$primary"]||primary=$(xrandr --query | awk '/ connected/{print $1; exit}')for m in$(xrandr --query | grep ' connected' | cut -d' ' -f1); do["$m"="$primary"]&&tray=right ||tray=none
MONITOR=$mTRAY_POSITION=$tray polybar --reload main &
doneelse polybar --reload main &
fi