scripts

misc scripts and tools
git clone git://git.2f30.org/scripts
Log | Files | Refs

mpdtoggle (457B)


      1 #!/bin/sh
      2 
      3 # play/stop toggle for mpd
      4 # depends: nc
      5 
      6 MPD_HOST=$(test -n "$MPD_HOST" && echo "$MPD_HOST" || echo localhost)
      7 MPD_PORT=$(test -n "$MPD_PORT" && echo "$MPD_PORT" || echo 6600)
      8 
      9 PLAYING() {
     10     echo status | nc $MPD_HOST $MPD_PORT | grep "^state: play$"
     11 }
     12 
     13 PLAY() {
     14     echo play | nc $MPD_HOST $MPD_PORT > /dev/null && echo play
     15 }
     16 
     17 STOP() {
     18     echo stop | nc $MPD_HOST $MPD_PORT > /dev/null && echo stop
     19 }
     20 
     21 test -z "$(PLAYING)" && PLAY || STOP