Implement quick and easy disable of xdg-open usage.
[midnight-commander.git] / misc / ext.d / web.sh.in
blob866d9ac502e2d9668b6e53a3d226ff053bd87f19
1 #!/bin/sh
3 # $1 - action
4 # $2 - type of file
6 action=$1
7 filetype=$2
9 [ -n "${MC_XDG_OPEN}" ] || MC_XDG_OPEN="xdg-open"
11 do_view_action() {
12 filetype=$1
14 case "${filetype}" in
15 html)
16 links -dump "${MC_EXT_FILENAME}" 2>/dev/null || \
17 w3m -dump "${MC_EXT_FILENAME}" 2>/dev/null || \
18 lynx -dump -force_html "${MC_EXT_FILENAME}"
22 esac
25 do_open_action() {
26 filetype=$1
28 case "${filetype}" in
29 html)
30 (if [ -n "@X11_WWW@" -a -n "$DISPLAY" ]; then
31 (@X11_WWW@ file://"${MC_EXT_CURRENTDIR}"/"${MC_EXT_BASENAME}" &) 1>&2
32 else
33 elinks "${MC_EXT_FILENAME}" || \
34 links "${MC_EXT_FILENAME}" || \
35 lynx -force_html "${MC_EXT_FILENAME}" || \
36 ${PAGER:-more} "${MC_EXT_FILENAME}"
37 fi) 2>/dev/null
41 esac
44 case "${action}" in
45 view)
46 do_view_action "${filetype}"
48 open)
49 "${MC_XDG_OPEN}" "${MC_EXT_FILENAME}" 2>/dev/null || \
50 do_open_action "${filetype}"
54 esac