#!/bin/bash
CPID=$(pgrep -x polybar)
if [ -n "${CPID}" ] ; then
kill -TERM ${CPID}
fi
# add window titles
# using bspc query here to get monitors in the same order bspwm sees them
for m in $( bspc query -M --names ); do
index=$((index + 1))
export P_BSPWM_WINDOW_CMD="tail ${HOME}/.cache/bspwm_windows_${index}.txt"
MONITOR=$m polybar --reload top &
MONITOR=$m polybar --reload bottom &
done