#!/bin/sh


# This gets run after ROX-Session is loaded and running as your session
# manager. ROX-Session will first try to load <Choices>/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.

[ -z "$XDG_CONFIG_HOME" ] && XDG_CONFIG_HOME=${HOME}/.config
[ -z "$XDG_CONFIG_DIRS" ] && XDG_CONFIG_DIRS=/etc/xdg

# If we're using Zero Install, start Zero Progress now so the user gets
# some feedback if nothing happens for a bit (because we're downloading)
if [ -d /uri/0install/zero-install.sourceforge.net ]; then
	0run "zero-install.sourceforge.net/apps/ZeroProgress 2004-03-26" &
fi

# Run any other stuff the user wants by searching all the
# .../ROX-Session/AutoStart directories...
# Intermediate var (ALL_XDG) necessary for dash
ALL_XDG="${XDG_CONFIG_HOME}:${XDG_CONFIG_DIRS}"
IFS=":"
for DIR in $ALL_XDG ; 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
