diff options
author | katherine <shmibs@shmibbles.me> | 2016-02-03 02:57:28 -0700 |
---|---|---|
committer | katherine <shmibs@shmibbles.me> | 2016-02-03 02:57:28 -0700 |
commit | 035321fe60cafc5d0481f6e06608527d4d9c67a6 (patch) | |
tree | d15d2c4125bf5357ff787c9e442f0a229706b547 | |
parent | 2ece2a2987dcbb28283f2337c466f755cdb9c007 (diff) | |
download | dotfiles-035321fe60cafc5d0481f6e06608527d4d9c67a6.tar.gz |
switcher.sh: cleaner implementation
-rwxr-xr-x | .config/herbstluftwm/switcher.sh | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/.config/herbstluftwm/switcher.sh b/.config/herbstluftwm/switcher.sh index 8ac60d1..b37ce9e 100755 --- a/.config/herbstluftwm/switcher.sh +++ b/.config/herbstluftwm/switcher.sh @@ -2,13 +2,20 @@ source ~/.config/init/vars -list=$(wmctrl -l) -IFS=$'\r\n' nums=($(echo $list | cut -d ' ' -f 1)) -choice=$(echo $list | cut -d ' ' -f 5- | nl -w 2 -s ") " | \ - dmenu -fn $efont -i -h $bheight -nb $bg_normal -nf $fg_normal \ - -sb $bg_focus -sf $fg_focus -p "Select:" -l 40 | \ - cut -d ')' -f 1) - -if [ $choice ]; then - herbstclient jumpto ${nums[$choice]} -fi +typeset -i choice +nums=() +lines="" +while read -rA line; do + nums=( "${nums[@]}" "${line[1]}" ) + if [[ -z "$lines" ]]; then + lines="${line[@]:3}" + else + lines="${lines}\n${line[@]:3}" + fi +done < <(wmctrl -l) + +echo -e "$lines" | nl -w 2 -s ") " | dmenu -fn $efont -i -h $bheight \ + -nb $bg_normal -nf $fg_normal -sb $bg_focus -sf $fg_focus \ + -p "Select:" -l 40 | cut -d ')' -f 1 | {read choice} + +herbstclient jumpto "${nums[$choice]}" |