#!/bin/sh

# This gets run after ROX-Session is loaded and running as your session
# manager, before Login is run.
#
# It is used to run ROX-Filer. If this process terminates, ROX-Session will
# offer to rerun it.
#
# $1 is the ROX-Session application directory.
#
# If you want to modify this file, you should first copy it as
# <Choices>/ROX-Session/RunROX so that upgrading ROX-Session will not overwrite
# your changes. This also allows per-user modifications.

if [ ! -n "$CHOICESPATH" ]; then
	CHOICESPATH=${HOME}/Choices:/usr/local/share/Choices:/usr/share/Choices
fi
IFS=":"

# Load ROX-Filer with a panel and a pinboard set up.
MYCHOICES="(none)"
for DIR in $CHOICESPATH; do
  if [ "$MYCHOICES" = "(none)" ]; then
    MYCHOICES="$DIR"
  fi
  PANEL="$DIR/ROX-Filer/pan_Default"
  if [ -f "$PANEL" ]; then
    break;
  fi;
  PANEL="";
done

if [ -z "$PANEL" -a -n "$MYCHOICES" ]; then
  "$1/SetupPanel" "$1" "$MYCHOICES"
fi

# The -n is needed to stop the filer going into the background, causing
# ROX-Session to offer to restart it...

# Try to run it though Zero Install...
if [ -d /uri/0install/rox.sourceforge.net ]; then
	exec 0run "rox.sourceforge.net/rox 2003-10-07" -n -p Default -b Default
fi

# Fallback to a manual installation
exec rox -n -p Default -b Default
