My build of nnn with minor changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

46 lines
1.1 KiB

  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. #
  8. # Shell: POSIX compliant
  9. # Author: Arun Prakash Jana
  10. selection=${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection
  11. cmd=$(pgrep -x mocp 2>/dev/null)
  12. ret=$cmd
  13. if [ -s "$selection" ]; then
  14. # try selection first
  15. if [ -z "$ret" ]; then
  16. # mocp not running
  17. mocp -S
  18. # clear selection and play
  19. cat "$selection" | xargs -0 mocp -acp
  20. else
  21. # mocp running, just append
  22. cat "$selection" | xargs -0 mocp -a
  23. fi
  24. else
  25. # ensure a file/dir is passed
  26. if ! [ -z "$1" ]; then
  27. if [ -z "$ret" ]; then
  28. # mocp not running
  29. mocp -S
  30. # clear selection and play
  31. mocp -acp "$1"
  32. else
  33. # mocp running, just append
  34. mocp -a "$1"
  35. fi
  36. fi
  37. fi
  38. # uncomment the line below to show mocp interface after appending
  39. # mocp