SHOW:
|
|
- or go back to the newest paste.
1 | #!/bin/bash | |
2 | ||
3 | function run-or-raise { | |
4 | pid=$(pgrep ${1} | head -n 1) | |
5 | ||
6 | # echo "$pid" # debug ... | |
7 | ||
8 | if [ -z "$pid" ]; then | |
9 | # echo "[info] $1 is not running" | |
10 | # launch application | |
11 | $1 & | |
12 | else | |
13 | - | echo "[info] found process $1 with pid $pid" |
13 | + | # echo "[info] found process $1 with pid $pid" |
14 | # get the window title | |
15 | window_title=`wmctrl -p -l | grep $pid | cut -d' ' -f7-` | |
16 | ||
17 | # bring the window to the front | |
18 | wmctrl -a "$window_title" | |
19 | fi | |
20 | ||
21 | } | |
22 | ||
23 | run-or-raise "$@" |