Просмотр исходного кода

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

Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
Yury V. Zaytsev 6 месяцев назад
Родитель
Сommit
572312bd88
3 измененных файлов с 24 добавлено и 19 удалено
  1. 11 3
      misc/ext.d/image.sh
  2. 3 1
      misc/ext.d/sound.sh
  3. 10 15
      misc/ext.d/video.sh

+ 11 - 3
misc/ext.d/image.sh

@@ -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

+ 3 - 1
misc/ext.d/sound.sh

@@ -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

+ 10 - 15
misc/ext.d/video.sh

@@ -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