web.sh.in 1.0 KB

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