#!/bin/sh


# This gets run after ROX-Session is loaded and running as your session
# manager. ROX-Session will first try to load 
# $XDG_CONFIG_HOME/rox.sourceforge.net/ROX-Session/Login, and only uses this
# if that is missing.
#
# This script should run any programs you want loaded when you log in and
# then exit. If you want to customise it, first copy it to
# ~/.config/rox.sourceforge.net/ROX-Session/Login and then edit that.
#
# See also the ROX-Session/RunROX script.
#
# $1 is the ROX-Session application directory.

if [ ! -n "$CHOICESPATH" ]; then
	CHOICESPATH=${HOME}/Choices:/usr/local/share/Choices:/usr/share/Choices
fi
if [ ! -n "$XDG_CONFIG_HOME" ]; then
	XDG_CONFIG_HOME=${HOME}/.config
fi
if [ ! -n "$XDG_CONFIG_DIRS" ]; then
	XDG_CONFIG_DIRS=/etc/xdg
fi
DIRS=$XDG_CONFIG_HOME:$XDG_CONFIG_DIRS
IFS=":"

# Run any other stuff the user wants by searching all the
# Choices/ROX-Session/AutoStart directories...

AS=
for DIR in $DIRS; do
  if [ -n "$DIR" ]; then
    AS="$DIR/rox.sourceforge.net/ROX-Session/AutoStart"
    for PROG in $AS/*; do
      if [ -d "$PROG" ]; then
    	  $PROG/AppRun &
      elif [ -x "$PROG" ]; then
	$PROG &
      fi
    done
  fi
done

if [ -z "$AS" ] ; then
for DIR in $CHOICESPATH; do
  if [ -n "$DIR" ]; then
    AS="$DIR/ROX-Session/AutoStart"
    for PROG in $AS/*; do
      if [ -d "$PROG" ]; then
    	  $PROG/AppRun &
      elif [ -x "$PROG" ]; then
	$PROG &
      fi
    done
  fi
done
fi
