28 lines
		
	
	
		
			469 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			28 lines
		
	
	
		
			469 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
#!/bin/bash
 | 
						|
if [ "x$1" != "x" ]
 | 
						|
then
 | 
						|
  pgrep -fx $1 1> /dev/null
 | 
						|
  if [ $? == "0" ]
 | 
						|
  then
 | 
						|
    echo "running"
 | 
						|
    ps aux | grep terminator > /home/balkian/LOG
 | 
						|
    WID=`xdotool search --class $1 | head -1`
 | 
						|
    wmctrl -i -a $WID
 | 
						|
    if [ "x$2" != "x" ]
 | 
						|
    then
 | 
						|
      eval "$2"
 | 
						|
    fi
 | 
						|
  else
 | 
						|
    if [ "x$3" == "x" ]
 | 
						|
    then
 | 
						|
      echo "not running"
 | 
						|
      /usr/bin/$1
 | 
						|
    else
 | 
						|
      eval "$3"
 | 
						|
    fi
 | 
						|
  fi
 | 
						|
else
 | 
						|
  echo "Usage: one-instance program-name [extra action]"
 | 
						|
fi
 | 
						|
 |