#!/usr/bin/env bash wm="monsterwm" ff="/tmp/monsterwm.fifo" tags=('main' 'www' 'chat' 'foo' 'bar') layouts=('[]=' '[ ]' 'T=' '[#]') conky -c $HOME/.conkyrc | dzen2 -bg '#000000' -h 18 -x 320 -ta r -e -p -fn "-*-ohsnap-medium-r-*-*-14-*-*-*-*-*-*-*" & # Check if it's a pipe, otherwise create it [[ -p $ff ]] || mkfifo -m 600 "$ff" while read -t 60 -r wmout || true; do desktops=( $(cut -d"|" -f1 <<< "$wmout") ) title="$(cut -d"|" -f2- <<< "$wmout")" if [[ "${desktops[@]}" =~ ^(([[:digit:]]+:)+[[:digit:]]+ ?)+$ ]]; then unset tmp for desktop in "${desktops[@]}"; do IFS=':' read -r d w m c u <<< "$desktop" # Tags labels label="${tags[$d]}" # Is this the current desktop ? save the layout ((c)) && fg="#ffffff" bg="#000000" && layout="${layouts[$m]}" \ || fg="#aaaaaa" bg="#000000" # Has windows ? ((w)) && fg="#395573" # Urgent windows ? ((u)) && fg="#ef2929" tmp+="^fg($fg)^bg($bg) $label ^bg()^fg()" done fi # Merge the clients indications, the tile and the info echo "$tmp $layout $title" done < "$ff" | dzen2 -bg '#000000' -w 320 -h 18 -ta l -e -p -fn "-*-ohsnap-medium-r-*-*-14-*-*-*-*-*-*-*" & while :; do "$wm" || break; done | tee -a "$ff"