[download]

local/bin/windows

   1 #!/bin/bash
   2 
   3 declare -A map
   4 print(){ # {{{
   5     while read id ws pid class host title; do
   6         printf '%s\t%s\t%s\t%s\n' \
   7         $id "${map[$ws]:-$ws}" "${class#*.}" "$title"
   8     done | column -ts $'\t'
   9 } # }}}
  10 
  11 while read id name; do
  12     map[$id]="$name "
  13 done < <(
  14     wmctrl -d | awk -F '  ' '{ print $1, $NF }'
  15 )
  16 
  17 wmctrl -lpx |
  18 sort -k 3,3nr -k 1,1gr |
  19 awk '$2 > -1' | print  |
  20 menu -i windows -l 10  |
  21 cut  -d ' ' -f 1 |
  22 xargs -r wmctrl -ia