diff options
author | Ben Sima <ben@bsima.me> | 2021-05-22 19:44:07 -0400 |
---|---|---|
committer | Ben Sima <ben@bsima.me> | 2021-05-22 19:44:07 -0400 |
commit | fed8d303c20b2acb12a678433caf4a76554d1dcd (patch) | |
tree | 43939e7b69fd4782cdca59b5407fab4b31af6d33 | |
parent | 1bbb1389bd314210fe4ab66515b0e9e2cb52827f (diff) |
add dswitcher
-rwxr-xr-x | dswitcher | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/dswitcher b/dswitcher new file mode 100755 index 0000000..00504a5 --- /dev/null +++ b/dswitcher @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +# Date format, for use as the prompt. +date=$(date +"%Y.%m.%d..%H.%M") + +# dmenu cannot display more than 30 lines, to avoid screen clutter. Only +# relevant if you have more than 30 windows open. +height=$(wmctrl -l | wc -l) +if [[ $height -gt 30 ]] + then heightfit=30 + else heightfit=$height +fi + +num=$(wmctrl -l \ + | sed 's/ / /' \ + | cut -d " " -f 4- \ + | nl -w 3 -n rn \ + | sed -r 's/^([ 0-9]+)[ \t]*(.*)$/\1 - \2/' \ + | dmenu -i -p "$date" -l $heightfit \ + | cut -d '-' -f -1 +) +[[ -z "$num" ]] && exit +wmctrl -l | sed -n "$num p" | cut -c -10 | xargs wmctrl -i -a |