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-03-07 04:20:30 +04:00
|
|
|
|
|
|
|
do_view_action() {
|
|
|
|
filetype=$1
|
|
|
|
|
|
|
|
case "${filetype}" in
|
|
|
|
*)
|
2024-09-11 09:45:25 +03:00
|
|
|
if command -v 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'
|
2024-09-11 09:45:25 +03:00
|
|
|
elif command -v mpv_identify.sh >/dev/null 2>&1; then
|
2018-06-02 15:16:41 +03:00
|
|
|
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
|
|
|
|
|
2024-09-11 09:45:25 +03:00
|
|
|
if command -v mpv >/dev/null 2>&1; then
|
2024-09-10 11:00:28 +03:00
|
|
|
PLAYER="mpv --really-quiet"
|
2020-01-01 17:54:52 +03:00
|
|
|
else
|
2024-09-10 11:00:28 +03:00
|
|
|
PLAYER="mplayer -really-quiet"
|
2020-01-01 17:54:52 +03:00
|
|
|
fi
|
|
|
|
|
2024-09-10 11:00:28 +03:00
|
|
|
if [ -n "$DISPLAY" ]; then
|
|
|
|
($PLAYER "${MC_EXT_FILENAME}" >/dev/null 2>&1 &)
|
|
|
|
else
|
|
|
|
$PLAYER -vo null "${MC_EXT_FILENAME}"
|
|
|
|
fi
|
2012-03-07 04:20:30 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|