#! /bin/bash

# kills any polybar currently on
killall -q polybar
# wait for termination
while pgrep -x polybar >/dev/null; do sleep 1; done
# loads polybar one every monitor based on calling param
if type "xrandr"; then
    for monitor in $(xrandr --query | grep " connected" | cut -d" " -f1); do
        MONITOR=$monitor polybar --reload $1 &
    done
else
    polybar --reload main-bar &
fi
