1
0
mirror of https://github.com/balkian/dotfiles.git synced 2024-09-16 08:41:42 +00:00
dotfiles/scripts/.bin/one-instance
J. Fernando Sánchez fc8c11d360 New config
2015-09-18 02:14:17 +02:00

28 lines
538 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`
CWID=`xdotool getactivewindow`
if [ "x$WID" != "x$CWID" ];
then
xdotool windowactivate $WID
#wmctrl -i -R $WID
else
xdotool windowminimize $WID
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