_mpd_helper 711 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. # variables
  2. mpc="/usr/bin/mpc -h $mpd_host"
  3. # functions
  4. function play_folder {
  5. tag = $1
  6. mkdir -p /music/$tag
  7. rm /music/$tag/.lastplay
  8. touch /music/$tag/.lastplay
  9. $mpc stop
  10. $mpc clear
  11. $mpc add $mpd_folder$tag
  12. _ensure_volume_10
  13. $mpc play
  14. }
  15. function mpd_play {
  16. $mpc stop
  17. $mpc clear
  18. $mpc add "$mpd_folder$1"
  19. _ensure_volume_10
  20. $mpc play 1
  21. }
  22. function mpd_play_shuffle {
  23. $mpc stop
  24. $mpc clear
  25. $mpc add "$1"
  26. $mpc shuffle
  27. _ensure_volume_10
  28. $mpc play 1
  29. }
  30. function mpd_set_volume {
  31. if [ -n "$1" ]; then # non-zero length
  32. $mpc volume $value
  33. fi
  34. }
  35. function _ensure_volume_10 {
  36. if (( $($mpc volume | grep -o '...%' | tr -d '%') < 10 )); then
  37. mpd_set_volume 10
  38. fi
  39. }