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
|
|
|
|
*)
|
2020-10-09 00:59:32 +03:00
|
|
|
if which mplayer >/dev/null 2>&1; then
|
2018-06-02 15:16:41 +03:00
|
|
|
mplayer -identify -vo null -ao null -frames 0 "${MC_EXT_FILENAME}" 2>&1 | \
|
|
|
|
sed -n 's/^ID_//p'
|
|
|
|
elif which mpv_identify.sh >/dev/null 2>&1; then
|
|
|
|
mpv_identify.sh "${MC_EXT_FILENAME}"
|
|
|
|
else
|
|
|
|
echo "Please install either mplayer or mpv to get information for this file"
|
|
|
|
fi
|
2012-03-07 04:20:30 +04:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
|
|
|
do_open_action() {
|
|
|
|
filetype=$1
|
|
|
|
|
2020-10-09 00:59:32 +03:00
|
|
|
if which mpv >/dev/null 2>&1; then
|
2020-01-01 17:54:52 +03:00
|
|
|
PLAYER=mpv
|
2020-10-09 00:59:32 +03:00
|
|
|
elif which mplayer >/dev/null 2>&1; then
|
2020-01-01 17:54:52 +03:00
|
|
|
PLAYER=mplayer
|
|
|
|
else
|
|
|
|
echo "Please install either mplayer or mpv to play this file"
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
2012-03-07 04:20:30 +04:00
|
|
|
case "${filetype}" in
|
|
|
|
*)
|
2012-06-26 16:39:31 +04:00
|
|
|
if [ -n "$DISPLAY" ]; then
|
2020-01-01 17:54:52 +03:00
|
|
|
($PLAYER "${MC_EXT_FILENAME}" >/dev/null 2>&1 &)
|
2012-06-26 16:39:31 +04:00
|
|
|
else
|
2020-01-01 17:54:52 +03:00
|
|
|
$PLAYER -vo null "${MC_EXT_FILENAME}"
|
2012-05-18 19:42:26 +04:00
|
|
|
fi
|
2012-03-07 04:20:30 +04:00
|
|
|
;;
|
|
|
|
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
|