#!/bin/sh
# $Id: do-image,v 1.1 2001/04/25 18:48:39 rbasch Exp $

. /mit/mimeutils/share/scripts/utils.sh

subtype=

usage() {
  echo "Usage: do-image [-s subtype] [-t content-type] <file>" 1>&2
  exit 1
}

while getopts s:t: opt; do
  case "$opt" in
    s)
      subtype=`echo "$OPTARG" | tr 'A-Z' 'a-z'`
      ;;
    t)
      subtype=`echo "$OPTARG" | awk -F/ '{ print $2; }' | tr 'A-Z' 'a-z'`
      ;;
    \?)
      usage
      ;;
  esac
done
shift `expr "$OPTIND" - 1`

if [ $# -ne 1 ]; then
  usage
fi

case "$subtype" in
  x-sgi-image)
    if [ -x /usr/sbin/imgview ]; then
      exec /usr/sbin/imgview -nofork "$1"
    else
      becho "No viewer for image/x-sgi-image on this platform."
      becho "Try an SGI workstation."
    fi
    ;;

  *)
    exec /bin/athena/attachandrun graphics xv xv "$1"
    ;;
esac
