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 action=$1
filetype=$2 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() { do_view_action() {
filetype=$1 filetype=$1
@ -50,10 +52,16 @@ do_open_action() {
else else
(gqview "${MC_EXT_FILENAME}" &) (gqview "${MC_EXT_FILENAME}" &)
fi 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 elif which see >/dev/null 2>&1; then
(see "${MC_EXT_FILENAME}" &) (see "${MC_EXT_FILENAME}" &)
else
(zgv "${MC_EXT_FILENAME}" &)
fi fi
;; ;;
esac esac

View File

@ -6,7 +6,9 @@
action=$1 action=$1
filetype=$2 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() { do_view_action() {
filetype=$1 filetype=$1

View File

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