web.sh.in 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/bin/sh
  2. # $1 - action
  3. # $2 - type of file
  4. action=$1
  5. filetype=$2
  6. [ -n "${MC_XDG_OPEN}" ] || MC_XDG_OPEN="xdg-open"
  7. do_view_action() {
  8. filetype=$1
  9. case "${filetype}" in
  10. html)
  11. links -dump "${MC_EXT_FILENAME}" 2>/dev/null || \
  12. w3m -dump "${MC_EXT_FILENAME}" 2>/dev/null || \
  13. lynx -dump -force_html "${MC_EXT_FILENAME}" 2>/dev/null ||
  14. cat "${MC_EXT_FILENAME}"
  15. ;;
  16. *)
  17. ;;
  18. esac
  19. }
  20. do_open_action() {
  21. filetype=$1
  22. case "${filetype}" in
  23. html)
  24. (if [ -n "@X11_WWW@" -a -n "$DISPLAY" ]; then
  25. (@X11_WWW@ file://"${MC_EXT_CURRENTDIR}"/"${MC_EXT_BASENAME}" &) 1>&2
  26. else
  27. elinks "${MC_EXT_FILENAME}" || \
  28. links "${MC_EXT_FILENAME}" || \
  29. lynx -force_html "${MC_EXT_FILENAME}" || \
  30. ${PAGER:-more} "${MC_EXT_FILENAME}"
  31. fi) 2>/dev/null
  32. ;;
  33. *)
  34. ;;
  35. esac
  36. }
  37. case "${action}" in
  38. view)
  39. do_view_action "${filetype}"
  40. ;;
  41. open)
  42. ("${MC_XDG_OPEN}" "${MC_EXT_FILENAME}" >/dev/null 2>&1) || \
  43. do_open_action "${filetype}"
  44. ;;
  45. *)
  46. ;;
  47. esac