#! /bin/sh

. "`dirname $0`/rcdefs"

case "$1" in
  start)
    if [ -n "${GPM}" ]
    then
      Print -n "Starting gpm... "
      # Remove gpm lock file (after unclean shutdown)
      ${BIN_RM} -f /tmp/gpm*

      if [ -n "${GPM_PROMPT}" ]
      then
        echo Please hold down the middle mouse button and press Return
        read junk
      fi

      ${GPM} ${GPM_OPTIONS}
      [ -n "${GPM_EXTRA}" ] && ${GPM} ${GPM_EXTRA}
      Print "done."
    fi
    ;;
  stop)
    if [ -n "${GPM}" ]
    then
      Print -n "Stopping gpm... "
      # Run asynchronously in case gpm hangs...
      ${GPM} -k &
      Print "done."
    fi
    ;;
  *)
    Usage "$0"
    exit 1
esac

exit 0
