#!/bin/ksh

# Script to return the name of the window manager that is running on
# the machine named by the single argument
#
MACHINE=`uname -s`
MACHINE=`sig_uname_filter $MACHINE`

case ${MACHINE} in
HP-UX )
  alias REMSH='remsh' ;;

* )
  alias REMSH='rsh' ;;
esac

if [ "$1" != "" ] ; then
  # Note that the error output must be closed to prevent error messages
  # from becoming mixed in, and the standard input must be directed away
  # from anything that might hang.
  #
  LIST="`REMSH $1 ps -e < /dev/null 2>&- | grep wm`"

  if   [ "${LIST##*[Mm]wm}"  != "${LIST}" ] ; then
    echo "MWM"
  elif [ "${LIST##*[Kk]wm}"  != "${LIST}" ] ; then
    echo "KWM"
  elif [ "${LIST##*[Dd]wm}"  != "${LIST}" ] ; then
    echo "DWM"
  elif [ "${LIST##*[Dd]twm}" != "${LIST}" ] ; then
    echo "DTWM"
  else
    echo "UNKNOWN"
  fi
fi
