hlfw.ca

hwwm

ref: 1b6c728d36011c3684b4a959925f91f133722c46
dir: /groupsbar/

View raw version
#!/usr/bin/env bash

# Number of groups
panels=6
declare -a item

# This is where webkit browsers currently break on the bar
# lsgrp 2 | tail -n1 gets something called `WebKitProcess` which is unmapped
for (( i = 1; i <= $panels; i++ )); do
  groups=$(lsgrp "$i" | tail -n1)
  if test "$groups" = "WebKitProcess"; then
    xprop -id "$groups" -remove _WM_GROUP
    groups="$(lsgrp 2 | tail -n1)"
  fi
  if [[ $groups != "" ]]; then
    if wattr m "$groups"; then
      item[$i]="◉"
    else
      item[$i]="◍"
    fi
  else
    item[$i]="◌"
  fi
  result+=${item["$i"]} 
done

printf '%s\n' "—${result[@]}—" > $XDG_RUNTIME_DIR/statusbar/groups