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 - with a few changes trying to incorporate windowtitles
#!/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#*:}" # the desktop number/id
w="${desk%%:*}" desk="${desk#*:}" # the desktop's client window count
l="${desk%%:*}" desk="${desk#*:}" # the desktop's tiling layout mode/id
c="${desk%%:*}" desk="${desk#*:}" # whether the desktop is the current focused (1) or not (0)
u="${desk%%|*}" desk="${desk#*|}" # whether any client in that desktop has received an urgent hint
title="${desk#0}" # window title (<== ADDED THIS)
# desktop id
case "$d" in
0) d="1" ;; 1) d="2" ;;
2) d="3" ;; 3) d="4" ;;
esac
# if current focused desktop (c==1)
if [ $c -eq 1 ]
then fg="&9" 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 (c==0) & has windows (w>0)
elif [ $c -eq 0 -a $w -ne 0 ]
then fg="&2" bg="&B6"
# if not current desktop (c==0) but has NO windows (w==0)
elif [ $w -eq 0 ]
then fg="&3" bg="&B0"
fi
# has urgent hint
[ $u -ne 0 ] && fg="&9" bg="&B0"
# construct the desktop tag display
deskinfo="$deskinfo$bg$fg $d "
unset bg fg
done
printf '%s%s %s\n' "$deskinfo" "$layout" "$title" # (<== ADDED $title)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment