3 # Description: Fetches the lyrics of the track currently playing in MOC
5 # Dependencies: ddgr (https://github.com/jarun/ddgr)
7 # Shell: POSIX compliant
8 # Author: Arun Prakash Jana
10 # Check if MOC server is running
11 cmd=$(pgrep -x mocp 2>/dev/null)
13 if [ -z "$ret" ]; then
20 # Check if anything is playing
21 state=$(echo "$out" | grep "State:" | cut -d' ' -f2)
22 if ! [ "$state" = 'PLAY' ]; then
26 # Try by Artist and Song Title first
27 ARTIST="$(echo "$out" | grep 'Artist:' | cut -d':' -f2 | sed 's/^[[:blank:]]*//;s/[[:blank:]]*$//')"
28 TITLE="$(echo "$out" | grep 'SongTitle:' | cut -d':' -f2 | sed 's/^[[:blank:]]*//;s/[[:blank:]]*$//')"
30 if [ -n "$ARTIST" ] && [ -n "$TITLE" ]; then
31 ddgr -w azlyrics.com --ducky "$ARTIST" "$TITLE"
34 FILENAME="$(basename "$(echo "$out" | grep 'File:' | cut -d':' -f2)")"
35 FILENAME="$(echo "${FILENAME%%.*}" | tr -d -)"
37 if [ -n "$FILENAME" ]; then
38 ddgr -w azlyrics.com --ducky "$FILENAME"