Merge branch '4524_cleanup'
[midnight-commander.git] / misc / ext.d / image.sh
blobc191225c89843075975a27a85ab3d49bb6bbbaf5
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 xpm)
16 [ -n "$DISPLAY" ] && sxpm "${MC_EXT_FILENAME}"
19 if which exif >/dev/null 2>&1; then
20 exif "${MC_EXT_FILENAME}" 2>/dev/null
21 E=$?
22 else
23 E=1
25 if [ $E != 0 ] && which exiftool >/dev/null 2>&1; then
26 exiftool "${MC_EXT_FILENAME}" 2>/dev/null
28 identify "${MC_EXT_FILENAME}"
30 esac
33 do_open_action() {
34 filetype=$1
36 case "${filetype}" in
37 xbm)
38 (bitmap "${MC_EXT_FILENAME}" &)
40 xcf)
41 (gimp "${MC_EXT_FILENAME}" &)
43 svg)
44 (inkscape "${MC_EXT_FILENAME}" &)
47 if [ -n "$DISPLAY" ]; then
48 if which geeqie >/dev/null 2>&1; then
49 (geeqie "${MC_EXT_FILENAME}" &)
50 else
51 (gqview "${MC_EXT_FILENAME}" &)
53 elif which see >/dev/null 2>&1; then
54 (see "${MC_EXT_FILENAME}" &)
55 else
56 (zgv "${MC_EXT_FILENAME}" &)
59 esac
62 case "${action}" in
63 view)
64 do_view_action "${filetype}"
66 open)
67 ("${MC_XDG_OPEN}" "${MC_EXT_FILENAME}" >/dev/null 2>&1) || \
68 do_open_action "${filetype}"
72 esac