#!/bin/bash

########################################################################
# -*- sh -*-                                                           #
#                                                                      #
# ~/.Xclients: used by startx (xinit) to start up a window manager and #
# any other clients you always want to start an X session with.        #
#                                                                      #
# feel free to edit this file to suit your needs.                      #
########################################################################

# these files are left sitting around by TheNextLevel.
rm -f $HOME/Xrootenv.0
rm -f /tmp/fvwmrc* 2>/dev/null

# First thing - check the user preferences
if [ -f $HOME/.wm_style ] ; then
    WMSTYLE=`cat $HOME/.wm_style`
    case "$WMSTYLE" in 
	Afterstep | AfterStep)
	    exec /usr/X11R6/bin/RunWM --AfterStep
	    ;;
	WindowMaker | Windowmaker | WMaker |  wmaker)
	    exec /usr/X11R6/bin/RunWM --WindowMaker
	    ;;
	Fvwm95 | fvwm95)
	    exec /usr/X11R6/bin/RunWM --Fvwm95
	    ;;
	Mwm | MWM | Lesstif)
	    exec /usr/X11R6/bin/RunWM --FvwmMWM
	    ;;
    esac
fi

# Default: Fvwm95
/usr/X11R6/bin/RunWM --Fvwm95 || {
    # gosh, neither fvwm95 nor fvwm2 is available;
    # let's try regular fvwm (AnotherLevel doesn't work with fvwm1).
    if [ -n "$(type -path fvwm)" ]; then
	# if this works, we stop here
	exec fvwm
    fi

    # wow, fvwm isn't here either ... 
    # use twm as a last resort.
    xterm &
    exec twm
}

