getsong 444 B

1234567891011121314151617181920
  1. #!/bin/sh
  2. # get current song title and artist from cmus otherwise 'paused'
  3. query=$(cmus-remote -Q 2>/dev/null)
  4. [ -z "${query}" ] && exit 0
  5. echo "${query}" | grep -q -x 'status paused' && echo paused && exit 0
  6. title=$(echo "${query}" \
  7. | sed -n 's/tag title //p' \
  8. )
  9. artist=$(echo "${query}" \
  10. | sed -n 's/tag artist //p' \
  11. )
  12. # print at most 20 characters of title and artist each
  13. printf "%s - %s\n" \
  14. "${title:0:20}" \
  15. "${artist:0:20}"