#!/bin/bash programs_to_stop='(surf|acroread|firefox)' pid() { action=$1; shift wid=$1; shift 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 getwindowfocus ) xdotool windowunmap $w_id pid "stop" $w_id exit 0 } wids() { x-window-list all | awk '$2 == "U" { print $0 }'; } cnt=$( wids | wc -l ) case "$cnt" in 0) echo "nothing banished?!?, exiting..." | dmenu exit 0;; 1) w_id=$( wids | awk '{ print $1 }' );; *) [[ "$cnt" -gt 5 ]] && cnt=5 w_id=$( wids | dmenu -l $cnt | awk '{print $1}' );; esac pid "cont" $w_id xdotool windowmap $w_id xdotool windowraise $w_id xdotool windowfocus $w_id