#!/bin/bash programs_to_stop='(surf|acroread|firefox)' pid() { action=$1 wid=$2 pid=$( xdotool getwindowpid $wid ) ps h -p $pid | grep -qsE "$programs_to_stop" || return 0 case $action in stop) kill -STOP $pid;; cont) kill -CONT $pid;; esac } [[ "$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 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