Implement quick and easy disable of xdg-open usage.
[midnight-commander.git] / misc / ext.d / image.sh
blob61e3bc212806ebcfd0799b539f39eed8845e0d7a
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 jpeg)
16 identify "${MC_EXT_FILENAME}"; test -x /usr/bin/exif && echo && exif "${MC_EXT_FILENAME}" 2>/dev/null
18 xpm)
19 sxpm "${MC_EXT_FILENAME}"
22 identify "${MC_EXT_FILENAME}"
24 esac
27 do_open_action() {
28 filetype=$1
30 case "${filetype}" in
31 xbm)
32 bitmap "${MC_EXT_FILENAME}"
34 xcf)
35 (gimp "${MC_EXT_FILENAME}" &)
37 svg)
38 (inkscape "${MC_EXT_FILENAME}" &)
41 if [ -n "$DISPLAY" ]; then
42 (gqview "${MC_EXT_FILENAME}" &)
43 elif see >/dev/null 2>&1; then
44 (see "${MC_EXT_FILENAME}" &)
45 else
46 zgv "${MC_EXT_FILENAME}"
49 esac
52 case "${action}" in
53 view)
54 do_view_action "${filetype}"
56 open)
57 "${MC_XDG_OPEN}" "${MC_EXT_FILENAME}" 2>/dev/null || \
58 do_open_action "${filetype}"
62 esac