#!/bin/sh

SCRIPT_PATH=`dirname $0`
SCRIPT_PATH=`cd $SCRIPT_PATH; pwd`

if [ "x$SCRIPT_PATH" = "x/build/gnome-do/src/gnome-do-0.95.3/Do/bin/Debug" ] ||
   [ "x$SCRIPT_PATH" = "x/build/gnome-do/src/gnome-do-0.95.3/Do" ] ; then
    echo "*** Running uninstalled ***"
    GNOME_DO_EXE="/build/gnome-do/src/gnome-do-0.95.3/Do/bin/Debug/Do.exe"
else
    GNOME_DO_EXE="/usr/lib/gnome-do/Do.exe"
fi

# Send the dbus Summon signal right away for fastest response if
# Do is already running.
dbus-send --session --type=method_call --dest='org.gnome.Do' \
	'/org/gnome/Do/Controller' 'org.gnome.Do.Controller.Summon'

# If Do is not running, run it.
if pgrep -u "`id -u`" '^gnome-do$' >/dev/null; then
	mono "$GNOME_DO_EXE" "$@"
fi
while [ "$?" -eq "20" ]; do
	mono "$GNOME_DO_EXE" "$@"
done
