#!/bin/sh
#
# Initialization script. Must be called from $HOME/.xinitrc or equivalent.
#

WDIR=$HOME/gnustep/Library/WindowMaker

# set root background color
if [ -f $WDIR/.rootbg ]; then
	sh $WDIR/.rootbg&
fi


rm -f .autodetect
#
# find image loader
(display -help >/dev/null ; echo "#define TILEROOT display -window root" > $WDIR/.autodetect ) ||
(xv -help 2> /dev/null ; echo "#define TILEROOT xv -root -quit -rmode 2" > $WDIR/.autodetect ) 

#
# find file selector
(xgetfile -h >/dev/null; echo '#define GETFILE(ttl) `xgetfile -title ttl`' >> $WDIR/.autodetect )

#
# savews
(savews >/dev/null; echo '#define SAVEWS savews' >> $WDIR/.autodetect ) ||
(/usr/local/GNUstep/Apps/WindowMaker.app/savews >/dev/null; echo '#define SAVEWS /usr/local/GNUstep/Apps/WindowMaker.app/savews' >> $WDIR/.autodetect ) ||
(/usr/GNUstep/Apps/WindowMaker.app/savews >/dev/null; echo '#define SAVEWS /usr/GNUstep/Apps/WindowMaker.app/savews' >> $WDIR/.autodetect )

# call saved clients
if [ -f $WDIR/.workspace_state ]; then
	sh $WDIR/.workspace_state
elif [ -f $HOME/.workspace_state ]; then
	sh $HOME/.workspace_state
fi

