Skip to content

Instantly share code, notes, and snippets.

@robstwd

robstwd/statusinfo.sh

Last active Dec 21, 2015
Embed
What would you like to do?
statusinfo.sh script copied form c00kiemon5ter's config. Successfully modified for my setup - ie single monitor, master and bipolarbar. Now for windowstitles
#!/usr/bin/env sh
# expects a line from monsterwm's output as argument ("$1")
# prints formatted output to be used as input for bipolarbar
# reference: original script from c00kiemon5ter -- https://github.com/c00kiemon5ter/scripts/blob/master/statusinfo.sh
# reference: bipolarbar by moetunes -- https://github.com/moetunes/bipolarbar
# bipolarbar expects colours as fg="&n" & bg="&Bn" where n=0-9
# desktop status
for desk; do
d="${desk%%:*}" desk="${desk#*:}" # desktop id
w="${desk%%:*}" desk="${desk#*:}" # window count
l="${desk%%:*}" desk="${desk#*:}" # layout mode
c="${desk%%:*}" desk="${desk#*:}" # is current desktop
u="${desk%%|*}" desk="${desk#*|}" # has urgent hint
# desktop id
case "$d" in
0) d="1" ;; 1) d="2" ;;
2) d="3" ;; 3) d="4" ;;
esac
# current desktop
if [ $c -ne 0 ]
then fg="&2" bg="&B8"
case "$l" in
0) s="T" ;; 1) s="M" ;; 2) s="B" ;;
3) s="G" ;; 4) s="#" ;; 5) s="F" ;;
esac && layout="&4&B0 $s"
# if not the current desktop & has windows
elif [ $c -eq 0 -a $w -ne 0 ]
then fg="&2" bg="&B6"
# if not current desktop but has NO windows
elif [ $w -eq 0 ]
then fg="&3" bg="&B0"
fi
# has urgent hint
[ $u -ne 0 ] && fg="&9" bg="&B0"
deskinfo="$deskinfo$bg$fg $d "
unset bg fg
done
printf '%s%s\n' "$deskinfo" "$layout"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment