#!/bin/sh
command="$@"

# First read /etc/profile and .profile
[ -r /etc/profile ] && . /etc/profile
[ -r "$HOME/.profile" ] && . "$HOME/.profile"

# Overwrite $LANG from /etc/profile (and friends) with the one picked in the
# greeter
if [ -n "$GDM_LANG" ]; then
  LANG="$GDM_LANG"
  export LANG
fi

# add session type specific XDG and gconf paths
if [ -n "$GDMSESSION" ]; then
  DEFAULT_XDG_CONFIG_DIRS='/etc/xdg'
  # readd default if was empty
  if [ -z "$XDG_CONFIG_DIRS" ]; then
    XDG_CONFIG_DIRS=$DEFAULT_XDG_CONFIG_DIRS
  fi
  export XDG_CONFIG_DIRS=${DEFAULT_XDG_CONFIG_DIRS}/xdg-${GDMSESSION}:$XDG_CONFIG_DIRS

  GCONF_PREFIX="/usr/share/gconf"
  export MANDATORY_PATH=${GCONF_PREFIX}/${GDMSESSION}.mandatory.path
  export DEFAULTS_PATH=${GCONF_PREFIX}/${GDMSESSION}.default.path
fi

# allow X access from VTs, etc.
xhost +si:localuser:`id -un` >/dev/null || :

# now run our session
eval exec dbus-launch --exit-with-session $command

echo "$0: Executing $command failed, will run xterm"

exec xterm -geometry 80x24+0+0
