foobar_control.sh 1.0 KB

1234567891011121314151617181920
  1. #! /bin/sh
  2. ## Dependencies: foo_beefweb for foobar2000, wmctrl, coreutils, grep, curl
  3. ## +x rights for this file
  4. case "$1" in
  5. "--help"|"-h") cat $0 ;;
  6. "--pause-toggle"|"-pt") curl -d "" "http://localhost:8880/api/player/pause/toggle" ;;
  7. "--play"|"-pl") curl -d "" "http://localhost:8880/api/player/play" ;;
  8. "--stop"|"-st") curl -d "" "http://localhost:8880/api/player/stop" ;;
  9. "--previous"|"-pv") curl -d "" "http://localhost:8880/api/player/previous" ;;
  10. "--next"|"-nx") curl -d "" "http://localhost:8880/api/player/next" ;;
  11. "--volume"|"-v") curl -d "{\"volume\":-`echo "100.0 - $2" | bc -l`}" "http://localhost:8880/api/player" ;; #Volume is in 1000db - XdB.
  12. # "--title"|"-t") xwininfo -root -children | grep "\[foobar2000\]" ;; ## Alternative
  13. "--title"|"-t") wmctrl -l | grep "\[foobar2000\]" | cut --complement -d' ' -f 1,2,3,4 | awk 'NF{NF--;};1' ;;
  14. *) echo "Invalid arguments, exitting..." && exit 1 ;;
  15. esac
  16. exit 0