My build of nnn with minor changes
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 
 
 

40 rindas
1.0 KiB

  1. #!/usr/bin/env sh
  2. # Description: Fetches the lyrics of the track currently playing in MOC
  3. # Dependencies: ddgr (https://github.com/jarun/ddgr)
  4. #
  5. # Shell: POSIX compliant
  6. # Author: Arun Prakash Jana
  7. # Check if MOC server is running
  8. cmd=$(pgrep -x mocp 2>/dev/null)
  9. ret=$cmd
  10. if [ -z "$ret" ]; then
  11. exit
  12. fi
  13. # Grab the output
  14. out="$(mocp -i)"
  15. # Check if anything is playing
  16. state=$(echo "$out" | grep "State:" | cut -d' ' -f2)
  17. if ! [ "$state" = 'PLAY' ]; then
  18. exit
  19. fi
  20. # Try by Artist and Song Title first
  21. ARTIST="$(echo "$out" | grep 'Artist:' | cut -d':' -f2 | sed 's/^[[:blank:]]*//;s/[[:blank:]]*$//')"
  22. TITLE="$(echo "$out" | grep 'SongTitle:' | cut -d':' -f2 | sed 's/^[[:blank:]]*//;s/[[:blank:]]*$//')"
  23. if ! [ -z "$ARTIST" ] && ! [ -z "$TITLE" ]; then
  24. ddgr -w azlyrics.com --ducky "$ARTIST" "$TITLE"
  25. else
  26. # Try by file name
  27. FILENAME="$(basename "$(echo "$out" | grep 'File:' | cut -d':' -f2)")"
  28. FILENAME="$(echo "${FILENAME%%.*}" | tr -d -)"
  29. if ! [ -z "$FILENAME" ]; then
  30. ddgr -w azlyrics.com --ducky "$FILENAME"
  31. fi
  32. fi