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.
 
 
 
 
 
 

46 lignes
1.4 KiB

  1. #!/usr/bin/env sh
  2. # Description: Play random music from current directory. Identifies MP3, FLAC, M4A, WEBM, WMA.
  3. # You may want to set GUIPLAYER.
  4. #
  5. # Shell: POSIX compliant
  6. # Author: Arun Prakash Jana
  7. GUIPLAYER="${GUIPLAYER}"
  8. NUMTRACKS="${NUMTRACKS:-100}"
  9. if [ ! -z "$GUIPLAYER" ]; then
  10. find . -type f \( -iname "*.mp3" -o -iname "*.flac" -o -iname "*.m4a" -o -iname "*.webm" -o -iname "*.wma" \) | shuf | head -n "$NUMTRACKS" | xargs -d "\n" "$GUIPLAYER" > /dev/null 2>&1 &
  11. # detach the player
  12. sleep 1
  13. elif which mocp >/dev/null 2>&1; then
  14. cmd=$(pgrep -x mocp 2>/dev/null)
  15. ret=$cmd
  16. if [ -z "$ret" ]; then
  17. # start MOC server
  18. mocp -S
  19. else
  20. # mocp running, check if it's playing
  21. state=$(mocp -i | grep "State:" | cut -d' ' -f2)
  22. if [ "$state" = 'PLAY' ]; then
  23. # add up to 100 random audio files
  24. find . -type f \( -iname "*.mp3" -o -iname "*.flac" -o -iname "*.m4a" -o -iname "*.webm" -o -iname "*.wma" \) | shuf | head -n "$NUMTRACKS" | xargs -d "\n" mocp -a
  25. exit
  26. fi
  27. fi
  28. # clear MOC playlist
  29. mocp -c
  30. # add up to 100 random audio files
  31. find . -type f \( -iname "*.mp3" -o -iname "*.flac" -o -iname "*.m4a" -o -iname "*.webm" -o -iname "*.wma" \) | shuf | head -n "$NUMTRACKS" | xargs -d "\n" mocp -a
  32. # start playing
  33. mocp -p
  34. else
  35. printf "moc missing"
  36. read -r _
  37. fi