#!/usr/bin/env bash wm=monsterwm ff="/tmp/$RANDOM.monsterwm.fifo" tags=('\ue010 null' '\ue011 web' '\ue012 foo' '\ue062') layouts=('\ue002' '\ue001' '\ue003' '\ue005' '\ue006') [[ -p $ff ]] || mkfifo -m 600 "$ff" function statusbar { # Date date=$(date +"%H:%M") # Memory usage mem=$(free -m | awk '/buffers\/cache/ {print $3 MB}') # Volume vol=$(amixer get Master | egrep -o '[0-9]{1,3}%' | sed -e 's/%//') # Music status music="$(mpc current -f "%artist% - %title%")" if [ -z "$music" ]; then music="stopped" mstat="\ue0ae" else mstat="$(mpc | sed -rn '2s/\[([[:alpha:]]+)].*/\1/p')" [ "$mstat" == "paused" ] && mstat="\ue059" || mstat="\ue0aa" fi # HDD root=$(df -h|awk '/root/ {print $5}') home=$(df -h|awk '/home/ {print $5}') echo "\r \f4$mstat\fr $music \f4\\ue09f\fr $root \f4\\ue0b2\fr $home \f4\ue020\fr $mem \f4\\ue05d\fr $vol \f4\ue015\fr $date " } while read -t 1 -r wmout || true; do if [[ $wmout =~ ^(([[:digit:]]+:)+[[:digit:]]+ ?)+$ ]]; then read -ra desktops <<< "$wmout" tmp= for desktop in "${desktops[@]}"; do IFS=':' read -r d w m c u <<< "$desktop" # Tags labels label=${tags[$d]} # Current desktop color and enclosing char (yes/no) ((c)) && fg="9" bg="2" lc="\u4 " rc=" \ur" && layout=${layouts[$m]} || fg="1" bg="0" lc=" " rc=" " # Has windows ? ((w)) && ((! c)) && fg="1" lc="\u6 " rc=" \ur" # Urgent windows ? ((u)) && fg="1" bg="3" lc="\u4 " rc=" \ur" tmp+="\f$fg\b$bg$lc$label$rc\fr\br" done # Merge the clients indications and the tile mode tmp+=" $layout" fi echo "$tmp $(statusbar)" done < "$ff" | bar & #while :; do "$wm" || break; done | tee -a "$ff" $wm > "$ff" rm $ff