scripts

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

commit b73098a4fbc1519d9e7e909cf5b1637e105ff899
parent 33302dc0a3ff30be5d2d6c940a01217133e5aea0
Author: lostd <lostd@2f30.org>
Date:   Wed,  2 Oct 2013 12:19:22 +0300

hard play/stop toggle (not pause) for the mpd (uses netcat, not mpc)

Diffstat:
Ampdtoggle | 21+++++++++++++++++++++
1 file changed, 21 insertions(+), 0 deletions(-)

diff --git a/mpdtoggle b/mpdtoggle @@ -0,0 +1,21 @@ +#!/bin/sh + +# play/stop toggle for mpd +# depends: nc + +MPD_HOST=$(test -n "$MPD_HOST" && echo "$MPD_HOST" || echo localhost) +MPD_PORT=$(test -n "$MPD_PORT" && echo "$MPD_PORT" || echo 6600) + +PLAYING() { + echo status | nc $MPD_HOST $MPD_PORT | grep "^state: play$" +} + +PLAY() { + echo play | nc $MPD_HOST $MPD_PORT > /dev/null && echo play +} + +STOP() { + echo stop | nc $MPD_HOST $MPD_PORT > /dev/null && echo stop +} + +test -z "$(PLAYING)" && PLAY || STOP