diff options
Diffstat (limited to '.local/bin/window-switcher')
-rwxr-xr-x | .local/bin/window-switcher | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/.local/bin/window-switcher b/.local/bin/window-switcher new file mode 100755 index 0000000..a184baa --- /dev/null +++ b/.local/bin/window-switcher @@ -0,0 +1,23 @@ +#!/bin/sh -u +# https://git.suckless.org/sites/file/tools.suckless.org/dmenu/scripts/switch.html + +windows=$(wmctrl -xl | + tr --squeeze-repeats '[:blank:]' | + tr '[:upper:]' '[:lower:]' | + cut --delimiter ' ' --fields 3-3,5- | + sed 's/^[a-zA-Z0-9-]*\.//' | + sort | + uniq) + +windows=$(printf "%s" "$windows" | + awk --assign list="$windows" \ + '{cur=length($1); printf $1; for(i=0; i < list - cur + 1; i++) printf " "; $1 = ""; printf "%s\n", $0}' 2> /dev/null) + +selection=$( + printf "%s" "$windows" | dmenu -nhf '#cf71e0' -sf '#cf71e0' -f -i -b -p ⠀:::⠀windows⠀::: + [ "$?" = 127 ] && kill -15 "$$" && "$0" +) + +target=$(printf "%s" "$selection" | tr --squeeze-repeats '[:blank:]' | cut --delimiter ' ' --fields 2-) + +[ -n "$target" ] && wmctrl -a "$target" |