My build of nnn with minor changes
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 
 

48 行
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 -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. mocp -o shuffle
  20. else
  21. # mocp running, check if it's playing
  22. state=$(mocp -i | grep "State:" | cut -d' ' -f2)
  23. if [ "$state" = 'PLAY' ]; then
  24. # add up to 100 random audio files
  25. find . -type f \( -iname "*.mp3" -o -iname "*.flac" -o -iname "*.m4a" -o -iname "*.webm" -o -iname "*.wma" \) | head -n "$NUMTRACKS" | xargs -d "\n" mocp -a
  26. exit
  27. fi
  28. fi
  29. # clear MOC playlist
  30. mocp -c
  31. mocp -o shuffle
  32. # add up to 100 random audio files
  33. find . -type f \( -iname "*.mp3" -o -iname "*.flac" -o -iname "*.m4a" -o -iname "*.webm" -o -iname "*.wma" \) | head -n "$NUMTRACKS" | xargs -d "\n" mocp -a
  34. # start playing
  35. mocp -p
  36. else
  37. printf "moc missing"
  38. read -r _
  39. fi