diff options
| author | Patrick <devnull@mailinator.com> | 2017-06-09 18:31:59 +0800 |
|---|---|---|
| committer | Patrick <devnull@mailinator.com> | 2017-06-09 18:31:59 +0800 |
| commit | d1694270d884515a3152cb6444f3d73911409a76 (patch) | |
| tree | 257ef5d914353b4f6d7651efa129a036a703af96 /scripts | |
| parent | 6296055b03839a50c8f0ae00fc1584b627ec86e2 (diff) | |
use x-window-list for list of unmapped windows
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/x-banish | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/scripts/x-banish b/scripts/x-banish index df9f939..469adda 100755 --- a/scripts/x-banish +++ b/scripts/x-banish @@ -1,5 +1,4 @@ #!/bin/bash -dir="${HOME}/.wm-banished" programs_to_stop='(surf|acroread|firefox)' pid() { @@ -13,29 +12,29 @@ pid() { esac } -[[ ! -d $dir ]] && mkdir -p $dir - -[[ "$1" = "clean" ]] && { - for i in $dir/*; do - [[ -f "$i" ]] && rm "$i" - done - exit 0 -} - [[ "$1" = "push" ]] && { w_id=$( xdotool search --maxdepth 1 --onlyvisible . 2>/dev/null | tail -1 ) xdotool windowunmap $w_id pid "stop" $w_id #echo "banished $(xdotool getwindowname $w_id)" | dmenu #~/bin/dmenu.sh - touch "${dir}/${w_id}" exit 0 } -w_id=$( ls -tr $dir | tail -1) -[[ "$w_id" = "" ]] && { - exit 0 -} +wids=$( x-window-list all | awk '$2 == "U" { print $1 }' ) +cnt=$( echo "$wids" | wc -w ) +case "$cnt" in + 0) + echo "nothing banished?!?, exiting..." + exit 0;; + 1) + w_id="$wids" + break;; + *) + [[ "$cnt" -gt 5 ]] && cnt=5 + w_id=$(echo $wids | dmenu -l $cnt );; +esac + + pid "cont" $w_id xdotool windowmap $w_id windowraise xdotool windowraise $w_id -rm -f "${dir}/${w_id}" |
