defaulthandler 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #!/bin/sh
  2. #barryk 2005. partial update 2008.
  3. #110304 fix from ozsouth.
  4. #130201 syntax error, missing fi.
  5. AFILE="`basename "$1"`"
  6. if [ "`echo -n "$AFILE" | grep '\.'`" = "" ];then
  7. #/usr/local/bin/defaulttexteditor "$1"
  8. exit
  9. fi
  10. #110304 fix from ozsouth...
  11. if [ "`echo -n "$1" | grep '^http:'`" != "" ];then
  12. /usr/local/bin/defaultbrowser "$1"
  13. exit
  14. fi
  15. if [ "`echo -n "$1" | grep '^www.'`" != "" ];then
  16. /usr/local/bin/defaultbrowser "http://""$1"
  17. exit
  18. else
  19. AEXT="`echo "$AFILE" | rev | cut -f 1 -d '.' | rev`"
  20. fi
  21. #this needs to be fleshed out a bit more...
  22. case $AEXT in
  23. txt|TXT)
  24. /usr/local/bin/defaulttexteditor "$1"
  25. ;;
  26. doc|DOC|rtf|RTF)
  27. /usr/local/bin/defaultwordprocessor "$1"
  28. ;;
  29. xls|XLS)
  30. /usr/local/bin/defaultspreadsheet "$1"
  31. ;;
  32. htm|html|HTM|HTML)
  33. #/usr/local/bin/defaulttexteditor "$1"
  34. /usr/local/bin/defaulthtmlviewer "$1"
  35. ;;
  36. png|PNG|gif|GIF|jpg|JPG|jpeg|JPEG|xpm|XPM)
  37. /usr/local/bin/defaultpaint "$1"
  38. ;;
  39. pdf|PDF|ps|PS|eps|EPS)
  40. epdfview "$1"
  41. ;;
  42. *)
  43. /usr/local/bin/defaulttexteditor "$1"
  44. ;;
  45. esac
  46. ###END###