#!/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 die pkill -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. if type xrandr >/dev/null 2>&1; then primary=$(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=$m TRAY_POSITION=$tray polybar --reload main & done else polybar --reload main & fi