Advertisement
Guest User

Untitled

a guest
Oct 30th, 2014
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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"
  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 "$@"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement