#!/bin/sh
# bottom-mobars [-k | N...]
#    Display a bottom bar on each of the listed screens, or kill them all.

. $HOME/.xmonad/lib/ws-utils.sh

USAGE="$0 [-hwk] screen...
    -h: print help text
    -w: show weather
    -k: kill bars
"

WEATHER=:
KILL=false
case $1 in
    (-h) echo "$USAGE"; exit;;
    (-w) WEATHER=weather; shift ;;
    (-k) KILL=true; shift;;
esac

# unconditionally kill existing bottom bars.
[ -z "$ZPIDS" ] || kill $ZPIDS
[ -z "$MPIDS" ] || kill $MPIDS
if $KILL; then
    exit 0
fi


status () {
    echo   $HOST '<fc=#eeeeee>'`monitor $1`'</fc>,' `weather`
}

for s in $*; do 
    while :; do status $s; sleep 10; done \
          | xmobar -x $((s - 1)) ~/.xmonad/xmobarrc-status > /dev/null &
done 

