summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorPatrick <devnull@mailinator.com>2017-06-10 11:54:45 +0800
committerPatrick <devnull@mailinator.com>2017-06-10 11:54:45 +0800
commit9949f1867f3c09c7cc51d68f057b33f4495e6b37 (patch)
tree73e29b5e9285e38805efb99fdbf52fb1e1bf2156 /scripts
parentd1694270d884515a3152cb6444f3d73911409a76 (diff)
clean up xdotool usage
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/x-banish24
1 files changed, 11 insertions, 13 deletions
diff --git a/scripts/x-banish b/scripts/x-banish
index 469adda..0ed16c9 100755
--- a/scripts/x-banish
+++ b/scripts/x-banish
@@ -2,8 +2,8 @@
programs_to_stop='(surf|acroread|firefox)'
pid() {
- action=$1
- wid=$2
+ action=$1; shift
+ wid=$1; shift
pid=$( xdotool getwindowpid $wid )
ps h -p $pid | grep -qsE "$programs_to_stop" || return 0
case $action in
@@ -13,28 +13,26 @@ pid() {
}
[[ "$1" = "push" ]] && {
- w_id=$( xdotool search --maxdepth 1 --onlyvisible . 2>/dev/null | tail -1 )
+ w_id=$( xdotool getwindowfocus )
xdotool windowunmap $w_id
pid "stop" $w_id
- #echo "banished $(xdotool getwindowname $w_id)" | dmenu #~/bin/dmenu.sh
exit 0
}
-wids=$( x-window-list all | awk '$2 == "U" { print $1 }' )
-cnt=$( echo "$wids" | wc -w )
+wids() { x-window-list all | awk '$2 == "U" { print $0 }'; }
+cnt=$( wids | wc -l )
case "$cnt" in
0)
- echo "nothing banished?!?, exiting..."
+ echo "nothing banished?!?, exiting..." | dmenu
exit 0;;
1)
- w_id="$wids"
- break;;
+ w_id=$( wids | awk '{ print $1 }' );;
*)
[[ "$cnt" -gt 5 ]] && cnt=5
- w_id=$(echo $wids | dmenu -l $cnt );;
+ w_id=$( wids | dmenu -l $cnt | awk '{print $1}' );;
esac
-
pid "cont" $w_id
-xdotool windowmap $w_id windowraise
-xdotool windowraise $w_id
+xdotool windowmap $w_id
+xdotool windowraise $w_id
+xdotool windowfocus $w_id