#!/bin/sh

# Choose a session-type:
#   kde
#   twm
#   fluxbox
#   solaris
#   xfce
#   windowmaker

x11session=fluxbox


# We want a new Authfile
rm -f .Xauthority

# merge in defaults and keymaps
[ -f /usr/X11R6/lib/X11/xinit/.Xresources ] && \
   xrdb -merge /usr/X11R6/lib/X11/xinit/.Xresources
[ -f /usr/X11R6/lib/X11/xinit/.Xmodmap ] && \
   xmodmap /usr/X11R6/lib/X11/xinit/.Xmodmap
[ -f $HOME/.Xresources ] && \
   xrdb -merge $HOME/.Xresources
[ -f $HOME/.Xmodmap ] && \
   xmodmap $HOME/.Xmodmap

# Set cursor and backgroundcolor
xsetroot -cursor_name left_ptr -solid SkyBlue4
# Set faster keyboard
xset r rate 250 30
# Set faster mouse
# Set powersavings

# Set a background picture
display +borderwidth -backdrop -window root $HOME/files/misc/wallpapers/black.png &

# Set up $KDEHOME if it is not there yet
if [ ! "$KDEHOME" ] ; then
	KDEHOME=$HOME/.kde
	export KDEHOME
fi

# Activate my fonts
my_fonts=$HOME/.fonts
if [ -d $my_fonts ] ; then
	mkfontdir $my_fonts
	xset +fp $my_fonts
	xset fp rehash
	# Get Ghostscript to look into my fontdir for additional Fontmap
	if [ -n "$GS_LIB" ] ; then
		GS_LIB=$my_fonts:$GS_LIB
		export GS_LIB
	fi
fi

# Start a session
if [ "$x11session" = kde ] ; then
	gkrellm &
	exec startkde
elif [ "$x11session" = twm ] ; then
	gkrellm &
	exec twm
elif [ "$x11session" = fluxbox ] ; then
	gkrellm -w &
	exec fluxbox
elif [ "$x11session" = solaris ] ; then
	if [ `uname` = SunOS ] ; then
		export OPENWINHOME=/usr/openwin
		export HELPPATH=$OPENWINHOME/help
		exec openwin
	else
		echo "This is not Solaris"
		exit 1
	fi
elif [ "$x11session" = xfce ] ; then
	gkrellm &
	exec xfce
elif [ "$x11session" = windowmaker ] ; then
	gkrellm &
	exec wmaker
else
	xterm &
	exec twm
fi

# eof
