#!/bin/sh

#
# xminicom	Run minicom in an xterm. This script looks for
#		color_xterm, rxvt and xterm (in that order) and
#		starts it up with minicom inside it.
#
# version	$Id: xminicom,v 1.2 2003/03/31 05:44:36 godisch Exp $

findcmd()
{
  IFS=:
  for i in $PATH
  do
	if [ -x $i\/$1 ]
	then
		result=$i\/$1
		IFS=
		return 0
	fi
  done
  result=
  IFS=
  return 1
}

if findcmd x-terminal-emulator
then
  exec $result -T minicom -e minicom -m -c on $*
  exit 1
fi

if findcmd color_xterm
then
  exec $result -bg black -fg grey -n minicom -geometry 80x25 -e minicom -m -c on $*
  exit 1
fi

if findcmd rxvt
then
  exec $result -bg black -fg grey -n minicom -T minicom -sl 0 -geometry 80x25 -e minicom -c on -m $*
  exit 1
fi

if findcmd kterm
then
  exec $result -n minicom -geometry 80x25 -e minicom -m $*
  exit 1
fi

if findcmd xterm
then
  if [ -f /etc/debian_version ]
  then
  exec $result -bg black -fg grey -n minicom -geometry 80x25 -e minicom -m -c on $*
  else
  exec $result -n minicom -geometry 80x25 -e minicom -m $*
  fi
  exit 1
fi

echo "xminicom: rxvt, color_xterm or xterm NOT found!" 1>&2
exit 1
