2012-03-07 04:20:30 +04:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# $1 - action
|
|
|
|
# $2 - type of file
|
|
|
|
|
|
|
|
action=$1
|
|
|
|
filetype=$2
|
|
|
|
|
2024-09-10 11:00:28 +03:00
|
|
|
if [ -n "$DISPLAY" ]; then
|
|
|
|
[ -n "${MC_XDG_OPEN}" ] || MC_XDG_OPEN="xdg-open"
|
|
|
|
fi
|
2012-12-18 09:43:06 +04:00
|
|
|
|
2012-03-07 04:20:30 +04:00
|
|
|
do_view_action() {
|
|
|
|
filetype=$1
|
|
|
|
|
|
|
|
case "${filetype}" in
|
|
|
|
xpm)
|
2024-01-13 16:13:38 +03:00
|
|
|
[ -n "$DISPLAY" ] && sxpm "${MC_EXT_FILENAME}"
|
2012-03-07 04:20:30 +04:00
|
|
|
;;
|
|
|
|
*)
|
2024-09-11 09:45:25 +03:00
|
|
|
if command -v exif >/dev/null 2>&1; then
|
2024-01-13 16:17:35 +03:00
|
|
|
exif "${MC_EXT_FILENAME}" 2>/dev/null
|
|
|
|
E=$?
|
|
|
|
else
|
|
|
|
E=1
|
|
|
|
fi
|
2024-09-11 09:45:25 +03:00
|
|
|
if [ $E != 0 ] && command -v exiftool >/dev/null 2>&1; then
|
2024-01-13 16:17:35 +03:00
|
|
|
exiftool "${MC_EXT_FILENAME}" 2>/dev/null
|
|
|
|
fi
|
2012-03-07 04:20:30 +04:00
|
|
|
identify "${MC_EXT_FILENAME}"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
|
|
|
do_open_action() {
|
|
|
|
filetype=$1
|
|
|
|
|
|
|
|
case "${filetype}" in
|
|
|
|
xbm)
|
2014-04-24 15:59:07 +04:00
|
|
|
(bitmap "${MC_EXT_FILENAME}" &)
|
2012-03-07 04:20:30 +04:00
|
|
|
;;
|
|
|
|
xcf)
|
|
|
|
(gimp "${MC_EXT_FILENAME}" &)
|
|
|
|
;;
|
2012-09-23 10:53:32 +04:00
|
|
|
svg)
|
|
|
|
(inkscape "${MC_EXT_FILENAME}" &)
|
|
|
|
;;
|
2012-03-07 04:20:30 +04:00
|
|
|
*)
|
2012-06-26 16:39:31 +04:00
|
|
|
if [ -n "$DISPLAY" ]; then
|
2024-09-11 09:45:25 +03:00
|
|
|
if command -v geeqie >/dev/null 2>&1; then
|
2019-01-21 19:50:04 +03:00
|
|
|
(geeqie "${MC_EXT_FILENAME}" &)
|
|
|
|
else
|
|
|
|
(gqview "${MC_EXT_FILENAME}" &)
|
|
|
|
fi
|
2024-09-10 11:00:28 +03:00
|
|
|
# no backgrounding for console viewers
|
2024-09-11 09:45:25 +03:00
|
|
|
elif command -v fim >/dev/null 2>&1; then
|
2024-09-10 11:00:28 +03:00
|
|
|
fim "${MC_EXT_FILENAME}"
|
2024-09-11 09:45:25 +03:00
|
|
|
elif command -v fbi >/dev/null 2>&1; then
|
2024-09-10 11:00:28 +03:00
|
|
|
fbi "${MC_EXT_FILENAME}"
|
2024-09-11 09:45:25 +03:00
|
|
|
elif command -v zgv >/dev/null 2>&1; then
|
2024-09-10 11:00:28 +03:00
|
|
|
zgv "${MC_EXT_FILENAME}"
|
|
|
|
# run-mailcap as a last resort
|
2024-09-11 09:45:25 +03:00
|
|
|
elif command -v see >/dev/null 2>&1; then
|
2012-10-05 12:24:30 +04:00
|
|
|
(see "${MC_EXT_FILENAME}" &)
|
2012-03-07 04:20:30 +04:00
|
|
|
fi
|
|
|
|
;;
|
|
|
|
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
|