sound.sh 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. common)
  13. mediainfo "${MC_EXT_FILENAME}"
  14. ;;
  15. mp3)
  16. mpg123 -vtn1 "${MC_EXT_FILENAME}" 2>&1 | \
  17. sed -n '/^Title/,/^Comment/p;/^MPEG/,/^Audio/p'
  18. ;;
  19. ogg)
  20. ogginfo "${MC_EXT_FILENAME}"
  21. ;;
  22. opus)
  23. opusinfo "${MC_EXT_FILENAME}"
  24. ;;
  25. wma)
  26. mplayer -quiet -slave -frames 0 -vo null -ao null -identify "${MC_EXT_FILENAME}" 2>/dev/null | \
  27. tail +13 || file "${MC_EXT_FILENAME}"
  28. ;;
  29. *)
  30. cat "${MC_EXT_FILENAME}"
  31. ;;
  32. esac
  33. }
  34. do_open_action() {
  35. filetype=$1
  36. case "${filetype}" in
  37. common)
  38. if [ -n "$DISPLAY" ]; then
  39. (audacious "${MC_EXT_FILENAME}" >/dev/null 2>&1 &)
  40. else
  41. play "${MC_EXT_FILENAME}"
  42. fi
  43. ;;
  44. mod)
  45. mikmod "${MC_EXT_FILENAME}"
  46. #tracker "${MC_EXT_FILENAME}"
  47. ;;
  48. wav22)
  49. vplay -s 22 "${MC_EXT_FILENAME}"
  50. ;;
  51. mp3)
  52. if [ -n "$DISPLAY" ]; then
  53. (audacious "${MC_EXT_FILENAME}" >/dev/null 2>&1 &)
  54. else
  55. mpg123 "${MC_EXT_FILENAME}"
  56. fi
  57. ;;
  58. ogg)
  59. if [ -n "$DISPLAY" ]; then
  60. (audacious "${MC_EXT_FILENAME}" >/dev/null 2>&1 &)
  61. else
  62. ogg123 "${MC_EXT_FILENAME}"
  63. fi
  64. ;;
  65. opus)
  66. if [ -n "$DISPLAY" ]; then
  67. (audacious "${MC_EXT_FILENAME}" >/dev/null 2>&1 &)
  68. else
  69. play "${MC_EXT_FILENAME}"
  70. fi
  71. ;;
  72. midi)
  73. timidity "${MC_EXT_FILENAME}"
  74. ;;
  75. wma)
  76. mplayer -vo null "${MC_EXT_FILENAME}"
  77. ;;
  78. playlist)
  79. if [ -n "$DISPLAY" ]; then
  80. (audacious -p "${MC_EXT_FILENAME}" >/dev/null 2>&1 &)
  81. else
  82. mplayer -vo null -playlist "${MC_EXT_FILENAME}"
  83. fi
  84. ;;
  85. *)
  86. ;;
  87. esac
  88. }
  89. case "${action}" in
  90. view)
  91. do_view_action "${filetype}"
  92. ;;
  93. open)
  94. ("${MC_XDG_OPEN}" "${MC_EXT_FILENAME}" >/dev/null 2>&1) || \
  95. do_open_action "${filetype}"
  96. ;;
  97. *)
  98. ;;
  99. esac