#!/bin/sh
#barryk 2005. partial update 2008.
#110304 fix from ozsouth.
#130201 syntax error, missing fi.

AFILE="`basename "$1"`"

if [ "`echo -n "$AFILE" | grep '\.'`" = "" ];then
 #/usr/local/bin/defaulttexteditor "$1"
 exit
fi

#110304 fix from ozsouth...
if [ "`echo -n "$1" | grep '^http:'`" != "" ];then
 /usr/local/bin/defaultbrowser "$1"
 exit
fi
if [ "`echo -n "$1" | grep '^www.'`" != "" ];then
 /usr/local/bin/defaultbrowser "http://""$1"
 exit
else
 AEXT="`echo "$AFILE" | rev | cut -f 1 -d '.' | rev`"
fi

#this needs to be fleshed out a bit more...
case $AEXT in
 txt|TXT) /usr/local/bin/defaulttexteditor "$1"  ;;
 #doc|DOC|rtf|RTF) /usr/local/bin/defaultwordprocessor "$1"  ;;
 #xls|XLS) /usr/local/bin/defaultspreadsheet "$1" ;;
 htm|html|HTM|HTML) /usr/local/bin/defaulthtmlviewer "$1" ;;
 png|PNG|gif|GIF|jpg|JPG|jpeg|JPEG|xpm|XPM)  /usr/local/bin/defaultimageviewer "$1" ;;
 pdf|PDF|ps|PS|eps|EPS) defaultpdfviewer "$1" ;;
 m3u) m3u-gui "$1" ;;

 *)
  #/usr/local/bin/defaulttexteditor "$1"
  /usr/bin/xdg-open "$1"
 ;;
esac

###END###
