2011-07-10 02:39:44 +00:00
|
|
|
#!/bin/bash
|
|
|
|
if [ "x$1" != "x" ]
|
|
|
|
then
|
|
|
|
pgrep -l -u "$USER" -f "$1" | egrep -v "/bin/bash|/bin/sh" | grep -vq "$$"
|
|
|
|
if [ $? == "0" ]
|
|
|
|
then
|
|
|
|
WID=`xdotool search --class $1 | head -1`
|
2015-09-04 09:58:09 +00:00
|
|
|
CWID=`xdotool getactivewindow`
|
|
|
|
if [ "x$WID" != "x$CWID" ];
|
2011-07-10 02:39:44 +00:00
|
|
|
then
|
2015-09-04 09:58:09 +00:00
|
|
|
xdotool windowactivate $WID
|
|
|
|
#wmctrl -i -R $WID
|
|
|
|
else
|
|
|
|
xdotool windowminimize $WID
|
2011-07-10 02:39:44 +00:00
|
|
|
fi
|
|
|
|
else
|
|
|
|
if [ "x$3" == "x" ]
|
|
|
|
then
|
|
|
|
/usr/bin/$1
|
|
|
|
else
|
|
|
|
eval "$3"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "Usage: one-instance program-name [extra action]"
|
|
|
|
fi
|
|
|
|
|