window-switcher.sh 518 B

12345678910111213141516171819
  1. #!/bin/bash
  2. # WTFPL
  3. # Require wmutils and wmctrl (hope to remove wmctrl soon)
  4. windows=""
  5. count=0
  6. for win in $(lsw)
  7. do
  8. name=$(xprop -id $win | grep "^WM_NAME" | cut -d '=' -f 2- | grep -oP "(?<=\").*(?=\")")
  9. windows=$windows"\n$win\t($count) $name"
  10. (( count++ ))
  11. done
  12. # doing this shitty space trim because dmenu seems to cut double spaces -_-
  13. window=$(echo -e $windows | sed '/^$/d' | cut -f 2- | dmenu -l 10 | tr -d " ")
  14. wid=$(echo -e $windows | tr -d " " | grep "$window" | cut -f 1)
  15. wmctrl -ia $wid