video.sh 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/bin/sh
  2. # $1 - action
  3. # $2 - type of file
  4. action=$1
  5. filetype=$2
  6. if [ -n "$DISPLAY" ]; then
  7. [ -n "${MC_XDG_OPEN}" ] || MC_XDG_OPEN="xdg-open"
  8. fi
  9. do_view_action() {
  10. filetype=$1
  11. case "${filetype}" in
  12. *)
  13. if command -v mplayer >/dev/null 2>&1; then
  14. mplayer -identify -vo null -ao null -frames 0 "${MC_EXT_FILENAME}" 2>&1 | \
  15. sed -n 's/^ID_//p'
  16. elif command -v mpv_identify.sh >/dev/null 2>&1; then
  17. mpv_identify.sh "${MC_EXT_FILENAME}"
  18. else
  19. echo "Please install either mplayer or mpv to get information for this file"
  20. fi
  21. ;;
  22. esac
  23. }
  24. do_open_action() {
  25. filetype=$1
  26. if command -v mpv >/dev/null 2>&1; then
  27. PLAYER="mpv --really-quiet"
  28. else
  29. PLAYER="mplayer -really-quiet"
  30. fi
  31. if [ -n "$DISPLAY" ]; then
  32. ($PLAYER "${MC_EXT_FILENAME}" >/dev/null 2>&1 &)
  33. else
  34. $PLAYER -vo null "${MC_EXT_FILENAME}"
  35. fi
  36. }
  37. case "${action}" in
  38. view)
  39. do_view_action "${filetype}"
  40. ;;
  41. open)
  42. ("${MC_XDG_OPEN}" "${MC_EXT_FILENAME}" >/dev/null 2>&1) || \
  43. do_open_action "${filetype}"
  44. ;;
  45. *)
  46. ;;
  47. esac