# !/bin/sh
# .xinitrc - OpenWindows startup script.
# Version 1.0, 19.11.92, Andy Schuerr

if [ -f $HOME/.Xdefaults ]
then
    xrdb $HOME/.Xdefaults		# Load Users X11 resource database
elif [ -f $PROGRESROOT/.Xdefaults ]
then
    xrdb $PROGRESROOT/.Xdefaults
elif [ -f $OPENWINHOME/lib/Xdefaults ]
    xrdb $OPENWINHOME/lib/Xdefaults ]
else
    echo "file .Xdefaults not found!"
    exit 1
fi

$OPENWINHOME/lib/openwin-sys 		# OpenWindows system initialization

# SunView binary compatibility is default mode.
[ -z "$NOSUNVIEW" -o "$NOSUNVIEW" -ne 1 ] && eval `svenv -env`


#
# Selection of the WindowManager
#

WINDOWMANAGER=${WINDOWMANAGER:-olwm}


if [ $WINDOWMANAGER = "olvwm" -o $WINDOWMANAGER = "olwm" ]
then
  sleep 15 & pid=$!			# Window Manager call
  $WINDOWMANAGER -syncpid $pid &				
  wait $pid				# Pause until WM inits
else
  sleep 15
  $WINDOWMANAGER &
  sleep 15
fi

if [ -f $HOME/.${WINDOWMANAGER}-init ]
then
  $HOME/.${WINDOWMANAGER}-init 		# Custom own WM tools
elif [ -f $PROGRESROOT/.${WINDOWMANAGER}-init ]
then
  $PROGRESROOT/.${WINDOWMANAGER}-init
elif [ $WINDOWMANAGER = "olvwm" -o $WINDOWMANAGER = "olwm" ]
then 
  if [ -f $HOME/.openwin-init ]
  then
    $HOME/.openwin-init			# Custom OpenWindows tools
  else
    $OPENWINHOME/lib/openwin-init   	# Default OpenWindows tools
  fi
fi

wait					# Wait for window manager to exit
