citadel

My dotfiles, scripts and nix configs
git clone git://jb55.com/citadel
Log | Files | Refs | README | LICENSE

dswitcher (649B)


      1 #!/usr/bin/env bash
      2 
      3 remove_useless() {
      4     if [ -z "$1" ]
      5     then
      6         cat
      7     else
      8         grep -v "$1"
      9     fi
     10 }
     11 
     12 # dmenu cannot display more than 30 lines, to avoid screen clutter. Only relevant if you have more than 30 windows open.
     13 height=$(wmctrl -l | wc -l)
     14 if [[ $height -gt 30 ]]
     15 	then heightfit=30
     16 	else heightfit=$height
     17 fi
     18 
     19 window=$(wmctrl -xl \
     20      | remove_useless "$1" \
     21      | sed 's/  / /' \
     22      | sed -r 's/^(0x.{8}) ([0-9]+) [^ \t]+\.([^ \t]+)[ \t]+[^ \t]+[ \t]+(.*)$/\2 - \3: \4 [\1]/' \
     23      | dmenu -i -p "windows" -l $heightfit \
     24      | sed -rn 's,.*\[(.{10})\],\1,p')
     25 
     26 [[ -z "$window" ]] && exit
     27 wmctrl -i -a "$window"