#!/usr/bin/env bash
monitor="$1"
gib_workspace_names() {
wmctrl -d \
| awk '{ print $1 " " $2 " " $9 }' \
| grep -v NSP \
| grep "${monitor}_"
}
gib_workspace_xml() {
gib_workspace_names | while read -r id active name; do
name="${name#*_}"
if [ "$active" == '*' ]; then
button_class="active_wsp"
elif wmctrl -l | grep --regexp '.*\s\+'"$id"'\s\+.*' >/dev/null; then
button_class="full_wsp"
else
button_class="inactive_wsp"
fi
echo -n ''
done
}
xprop -spy -root _NET_CURRENT_DESKTOP | while read -r; do
echo ''"$(gib_workspace_xml)"''
done