#!/bin/bash
# wrapper script for wdm
# written by MATSUBAYASHI 'Shaolin' Kohji <shaolin@rhythmaning.org>
# modified by Yasuyuki Furukawa <yasu@on.cs.keio.ac.jp>

# create /etc/X11/wdm/GNUstep (it is needed to exist to run wdmLogin)
#   taken from /usr/X11R6/bin/RunWM and slightly tailored...
#
if [ -x /usr/X11R6/bin/wdwrite -a -d /etc/X11/WindowMaker ] ; then
  WMDEFDIR="/etc/X11/WindowMaker"
  GSDIR=/etc/X11/wdm/GNUstep
  [ -d $GSDIR/Defaults -a -f $WMDEFDIR/WMGLOBAL ] || {
      /bin/mkdir -p $GSDIR/Defaults
      /bin/cp -f $WMDEFDIR/WMGLOBAL $GSDIR/Defaults
      /usr/X11R6/bin/wdwrite WMGLOBAL MultiByteText "YES"
  }
else
  /bin/cat <<EOF
 WARNING: You must have WindowMaker installed to run wdm.
 Please install WindowMaker first, then retry installing
 wdm again.
EOF
fi

# reconfig /etc/X11/wdm/wdm-config again
#
/etc/X11/wdm/wdmReconfig


# finally, execute wdm binary itself
#
exec /usr/X11R6/bin/wdm.bin $*

# wrapper script ends here
