Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- function run-or-raise {
- pid=$(pgrep ${1} | head -n 1)
- # echo "$pid" # debug ...
- if [ -z "$pid" ]; then
- # echo "[info] $1 is not running"
- # launch application
- $1 &
- else
- # echo "[info] found process $1 with pid $pid"
- # get the window title
- window_title=`wmctrl -p -l | grep $pid | cut -d' ' -f7-`
- # bring the window to the front
- wmctrl -a "$window_title"
- fi
- }
- run-or-raise "$@"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement