mpdFunctions.sh 631 B

12345678910111213141516171819202122232425262728
  1. #!/bin/bash
  2. display_song() {
  3. status=
  4. color=
  5. # mpcOut = "$(mpc status | sed 1d | head -n1)"
  6. # case $(echo $mpcOut | awk '{ print $1 }') in
  7. case $(mpc status | sed 1d | head -n1 | awk '{ print $1 }') in
  8. '[playing]')
  9. status=♪
  10. color="#FFFFFF"
  11. ;;
  12. '[paused]')
  13. status=X
  14. color="#FF0000"
  15. ;;
  16. esac
  17. # time = $(mpc status | sed 1d | head -n1 | awk '{ print $3 }')
  18. echo '[{"name": "mpd", "instance": "now playing", "full_text": "'${status}' '$1'", "color": "'${color}'"}] '
  19. }
  20. (while :; do
  21. display_song "$(mpc current --wait)"
  22. done) &
  23. while :; do
  24. display_song "$(mpc current)"
  25. mpc idle player > /dev/null
  26. done