1
0
mirror of https://github.com/balkian/dotfiles.git synced 2024-11-05 13:11:43 +00:00
dotfiles/bin/one-instance
J.Fernando Sánchez d8f23e0276 Removed personal-scripts submodule
To make my life a bit easier
2013-06-20 17:54:47 +02:00

25 lines
425 B
Bash
Executable File

#!/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`
wmctrl -i -a $WID
if [ "x$2" != "x" ]
then
eval "$2"
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