#!/bin/sh

# This script will launch windowmaker and make sure
# configurations are set up correctly

add()
{
   if [ ! -r /mit/$1/ ]; then
     attach -h -n -q -a -r $1
   fi
   PATH=${PATH}:/mit/$1/`athdir /mit/$1`; export PATH
   MANPATH=${MANPATH}:/mit/$1/man
}

add graphics
add gnu
add newtex
add sipb
add infoagents
add outland
add windowmanagers
add desk
add games
add acro
add xemacs

PATH=${PATH}:/mit/windowmanagers/libexec/; export PATH

echo "You are using a VERY BETA WINDOWMANAGER : 0.51.0"
echo "Please be aware there may be problems"
echo "If it's having errors, delete your config files:"
echo "     rm -rf ~/GNUstep"
echo ""

zwrite -d -q -s "windowmaker zephyr" -n $USER \
       -m "You are using a BETA windowmanager: WindowMaker 0.51.0 .
You may lose. If you are losing, please try deleting your config files 
by typing: 
     rm -rf ~/GNUstep"

GLOBALDIR="/mit/windowmanagers/share/WindowMaker"
GNUSTEP_LOCAL_ROOT="/mit/windowmanagers/share/GNUstep"; export GNUSTEP_LOCAL_ROOT

if [ ! -d $GLOBALDIR ]; then
      echo "Could not find global configurations files"
      echo "Make sure you ran 'attach windowmanagers'"
      exit 1
fi

if test "x$GNUSTEP_USER_ROOT" = "x"; then
        if [ ! -d $HOME/GNUstep ]; then
                echo "Configuring WindowMaker for the first time"
		sh /mit/windowmanagers/libexec//wmaker.inst
        fi
fi

if [ -f ~/GNUstep/Library/WindowMaker/.workspace_state ]; then
        sh ~/GNUstep/Library/WindowMaker/.workspace_state &
fi

exec wmaker "$@"
