My build of nnn with minor changes
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

mocplay 1.9 KiB

il y a 4 ans
il y a 4 ans
il y a 5 ans
il y a 4 ans
il y a 5 ans
il y a 5 ans
il y a 5 ans
il y a 5 ans
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #!/usr/bin/env sh
  2. # Description: Appends and optionally plays music in MOC
  3. #
  4. # Notes:
  5. # - if selection is available, plays it, else plays the current file or directory
  6. # - appends tracks and exits is MOC is running, else clears playlist and adds tracks
  7. # - to let mocp shuffle tracks, set SHUFFLE=1
  8. #
  9. # Shell: POSIX compliant
  10. # Authors: Arun Prakash Jana, ath3
  11. IFS="$(printf '\n\r')"
  12. selection=${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection}
  13. cmd=$(pgrep -x mocp 2>/dev/null)
  14. ret=$cmd
  15. SHUFFLE="${SHUFFLE:-0}"
  16. mocp_add ()
  17. {
  18. if [ "$SHUFFLE" = 1 ]; then
  19. if [ "$resp" = "y" ]; then
  20. arr=$(tr '\0' '\n' < "$selection")
  21. elif [ -n "$1" ]; then
  22. arr="$1"
  23. fi
  24. for entry in $arr
  25. do
  26. if [ -d "$entry" ]; then
  27. arr2=$arr2$(find "$entry" -type f \( ! -iname "*.m3u" ! -iname "*.pls" \))
  28. elif echo "$entry" | grep -qv '\.m3u$\|\.pls$' ; then
  29. arr2=$(printf "%s\n%s" "$entry" "$arr2")
  30. fi
  31. done
  32. mocp -o shuffle
  33. echo "$arr2" | xargs -d "\n" mocp -a
  34. else
  35. if [ "$resp" = "y" ]; then
  36. xargs < "$selection" -0 mocp -a
  37. else
  38. mocp -a "$1"
  39. fi
  40. fi
  41. }
  42. if [ ! -s "$selection" ] && [ -z "$1" ]; then
  43. exit
  44. fi
  45. if [ "$2" = "opener" ]; then
  46. :
  47. elif [ -s "$selection" ]; then
  48. printf "Work with selection? Enter 'y' to confirm: "
  49. read -r resp
  50. fi
  51. if [ -z "$ret" ]; then
  52. # mocp not running
  53. mocp -S
  54. else
  55. # mocp running, check if it's playing
  56. state=$(mocp -i | grep "State:" | cut -d' ' -f2)
  57. if [ "$state" = 'PLAY' ]; then
  58. # add to playlist and exit
  59. mocp_add "$1"
  60. # uncomment the line below to show mocp interface after appending
  61. # mocp
  62. exit
  63. fi
  64. fi
  65. # clear selection and play
  66. mocp -c
  67. mocp_add "$1" "$resp"
  68. mocp -p
  69. # uncomment the line below to show mocp interface after appending
  70. # mocp