Ticket #4479: prioritize console players for audio/video and images

Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
This commit is contained in:
Yury V. Zaytsev 2024-09-10 10:00:28 +02:00
parent 84af354d2a
commit 572312bd88
3 changed files with 24 additions and 19 deletions

View File

@ -6,7 +6,9 @@
action=$1
filetype=$2
[ -n "${MC_XDG_OPEN}" ] || MC_XDG_OPEN="xdg-open"
if [ -n "$DISPLAY" ]; then
[ -n "${MC_XDG_OPEN}" ] || MC_XDG_OPEN="xdg-open"
fi
do_view_action() {
filetype=$1
@ -50,10 +52,16 @@ do_open_action() {
else
(gqview "${MC_EXT_FILENAME}" &)
fi
# no backgrounding for console viewers
elif which fim >/dev/null 2>&1; then
fim "${MC_EXT_FILENAME}"
elif which fbi >/dev/null 2>&1; then
fbi "${MC_EXT_FILENAME}"
elif which zgv >/dev/null 2>&1; then
zgv "${MC_EXT_FILENAME}"
# run-mailcap as a last resort
elif which see >/dev/null 2>&1; then
(see "${MC_EXT_FILENAME}" &)
else
(zgv "${MC_EXT_FILENAME}" &)
fi
;;
esac

View File

@ -6,7 +6,9 @@
action=$1
filetype=$2
[ -n "${MC_XDG_OPEN}" ] || MC_XDG_OPEN="xdg-open"
if [ -n "$DISPLAY" ]; then
[ -n "${MC_XDG_OPEN}" ] || MC_XDG_OPEN="xdg-open"
fi
do_view_action() {
filetype=$1

View File

@ -6,7 +6,9 @@
action=$1
filetype=$2
[ -n "${MC_XDG_OPEN}" ] || MC_XDG_OPEN="xdg-open"
if [ -n "$DISPLAY" ]; then
[ -n "${MC_XDG_OPEN}" ] || MC_XDG_OPEN="xdg-open"
fi
do_view_action() {
filetype=$1
@ -29,23 +31,16 @@ do_open_action() {
filetype=$1
if which mpv >/dev/null 2>&1; then
PLAYER=mpv
elif which mplayer >/dev/null 2>&1; then
PLAYER=mplayer
PLAYER="mpv --really-quiet"
else
echo "Please install either mplayer or mpv to play this file"
return
PLAYER="mplayer -really-quiet"
fi
case "${filetype}" in
*)
if [ -n "$DISPLAY" ]; then
($PLAYER "${MC_EXT_FILENAME}" >/dev/null 2>&1 &)
else
$PLAYER -vo null "${MC_EXT_FILENAME}"
fi
;;
esac
if [ -n "$DISPLAY" ]; then
($PLAYER "${MC_EXT_FILENAME}" >/dev/null 2>&1 &)
else
$PLAYER -vo null "${MC_EXT_FILENAME}"
fi
}
case "${action}" in