fore (356B) (RAW)
1 #!/bin/sh 2 3 # (f)ocus (or) (e)xecute a script/program depending of if it's 4 # already running or not. 5 6 focus() { 7 xdotool search --onlyvisible "^${1}$" windowactivate 2> /dev/null 8 } 9 10 if [ $# -lt 1 ] 11 then 12 printf 'usage: %s command\n' "${0##*/}" 13 exit 1 14 fi 15 16 case "$1" in 17 -t) shift; focus "$1" || "$TERMINAL" -T "$1" -e "$@" ;; 18 *) focus "$1" || "$@" ;; 19 esac