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 || \
|
2019-11-09 10:06:16 +03:00
|
|
|
lynx -dump -force_html "${MC_EXT_FILENAME}" 2>/dev/null ||
|
|
|
|
cat "${MC_EXT_FILENAME}"
|
2012-03-07 04:20:30 +04:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
;;
|
|
|
|
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)
|
2016-02-14 08:40:57 +03:00
|
|
|
("${MC_XDG_OPEN}" "${MC_EXT_FILENAME}" >/dev/null 2>&1) || \
|
2012-03-07 04:20:30 +04:00
|
|
|
do_open_action "${filetype}"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|