image.sh 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #!/bin/sh
  2. # $1 - action
  3. # $2 - type of file
  4. action=$1
  5. filetype=$2
  6. do_view_action() {
  7. filetype=$1
  8. case "${filetype}" in
  9. jpeg)
  10. identify "${MC_EXT_FILENAME}"; test -x /usr/bin/exif && echo && exif "${MC_EXT_FILENAME}" 2>/dev/null
  11. ;;
  12. xpm)
  13. sxpm "${MC_EXT_FILENAME}"
  14. ;;
  15. *)
  16. identify "${MC_EXT_FILENAME}"
  17. ;;
  18. esac
  19. }
  20. do_open_action() {
  21. filetype=$1
  22. case "${filetype}" in
  23. xbm)
  24. bitmap "${MC_EXT_FILENAME}"
  25. ;;
  26. xcf)
  27. (gimp "${MC_EXT_FILENAME}" &)
  28. ;;
  29. svg)
  30. (inkscape "${MC_EXT_FILENAME}" &)
  31. ;;
  32. *)
  33. if [ -n "$DISPLAY" ]; then
  34. (gqview "${MC_EXT_FILENAME}" &)
  35. elif see >/dev/null 2>&1; then
  36. (see "${MC_EXT_FILENAME}" &)
  37. else
  38. zgv "${MC_EXT_FILENAME}"
  39. fi
  40. ;;
  41. esac
  42. }
  43. case "${action}" in
  44. view)
  45. do_view_action "${filetype}"
  46. ;;
  47. open)
  48. xdg-open "${MC_EXT_FILENAME}" 2>/dev/null || \
  49. do_open_action "${filetype}"
  50. ;;
  51. *)
  52. ;;
  53. esac