2012-03-07 04:20:30 +04:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# $1 - action
|
|
|
|
# $2 - type of file
|
|
|
|
|
|
|
|
action=$1
|
|
|
|
filetype=$2
|
|
|
|
|
2012-12-18 09:43:06 +04:00
|
|
|
[ -n "${MC_XDG_OPEN}" ] || MC_XDG_OPEN="xdg-open"
|
|
|
|
|
2012-03-07 04:20:30 +04:00
|
|
|
do_view_action() {
|
|
|
|
filetype=$1
|
|
|
|
|
|
|
|
case "${filetype}" in
|
|
|
|
html)
|
|
|
|
links -dump "${MC_EXT_FILENAME}" 2>/dev/null || \
|
|
|
|
w3m -dump "${MC_EXT_FILENAME}" 2>/dev/null || \
|
|
|
|
lynx -dump -force_html "${MC_EXT_FILENAME}"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
|
|
|
do_open_action() {
|
|
|
|
filetype=$1
|
|
|
|
|
|
|
|
case "${filetype}" in
|
|
|
|
html)
|
2012-05-18 19:42:26 +04:00
|
|
|
(if [ -n "@X11_WWW@" -a -n "$DISPLAY" ]; then
|
2012-03-07 04:20:30 +04:00
|
|
|
(@X11_WWW@ file://"${MC_EXT_CURRENTDIR}"/"${MC_EXT_BASENAME}" &) 1>&2
|
|
|
|
else
|
2012-05-18 19:42:26 +04:00
|
|
|
elinks "${MC_EXT_FILENAME}" || \
|
|
|
|
links "${MC_EXT_FILENAME}" || \
|
2012-03-07 04:20:30 +04:00
|
|
|
lynx -force_html "${MC_EXT_FILENAME}" || \
|
|
|
|
${PAGER:-more} "${MC_EXT_FILENAME}"
|
|
|
|
fi) 2>/dev/null
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
|
|
|
case "${action}" in
|
|
|
|
view)
|
|
|
|
do_view_action "${filetype}"
|
|
|
|
;;
|
|
|
|
open)
|
2012-12-18 09:43:06 +04:00
|
|
|
"${MC_XDG_OPEN}" "${MC_EXT_FILENAME}" 2>/dev/null || \
|
2012-03-07 04:20:30 +04:00
|
|
|
do_open_action "${filetype}"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|