#! /bin/sh
#
# Run xboard with phalanx as chess program.
#
# Copyright (c) 1999, 2000 SuSE GmbH Nuernberg, Germany.  All rights reserved.
#
# Author: Steffen Winterfeldt <wfeldt@suse.de>
#
# Fixed for Phalanx: Pavel Janik ml. <Pavel.Janik@suse.cz>

[ "$DISPLAY" ] || {
  echo >&2 "This is not a text mode application!"
  exit 63
}

emsg="You\'ll have to install package \'xboard\' first to run xphalanx."

which xboard >/dev/null 2>&1 || {
  if tty -s ; then
    sh -c "echo >&2 $emsg"
  else
    xterm +sb -T "xphalanx error" -bg white -fg red -e sh -c "echo $emsg ; read"
  fi
  exit 42
}

exec xboard -fcp phalanx -scp phalanx "$@"
