tadd minimpc script - scripts - random scripts
 (HTM) git clone git://parazyd.org/scripts.git
 (DIR) Log
 (DIR) Files
 (DIR) Refs
       ---
 (DIR) commit fcf26e89dd51bd2e11694c9a2b8546f364bbd349
 (DIR) parent a38ad4e15a33dd173f8e68bc3507e2146a2e5c44
 (HTM) Author: parazyd <parazyd@dyne.org>
       Date:   Wed, 20 Jul 2016 19:35:46 +0200
       
       add minimpc script
       
       Diffstat:
         A minimpc                             |      49 +++++++++++++++++++++++++++++++
       
       1 file changed, 49 insertions(+), 0 deletions(-)
       ---
 (DIR) diff --git a/minimpc b/minimpc
       t@@ -0,0 +1,49 @@
       +#!/bin/sh
       +#
       +# parazyd - (c) wtfpl 2016
       +# rudimentary mpd controls
       +
       +MPDHOST=${MPDHOST:-"/home/parazyd/.config/mpd/mpd.sock"}
       +# MPDHOST=${MPDHOST:-"127.0.0.1 6600"}
       +
       +if [[ $MPDHOST == /* ]] || [[ $MPDHOST == ~/* ]]; then
       +        NCARGS="-U"
       +else
       +        NCARGS=""
       +fi
       +
       +toggle() {
       +        playing() {
       +                echo status | nc $NCARGS $MPDHOST | grep "^state: play$"
       +        }
       +
       +        play() {
       +                echo play | nc $NCARGS $MPDHOST > /dev/null
       +        }
       +
       +        pause() {
       +                echo pause | nc $NCARGS $MPDHOST > /dev/null
       +        }
       +
       +        test -z "$(playing)" && play || pause
       +}
       +
       +next() {
       +        echo next | nc $NCARGS $MPDHOST $MPDPORT > /dev/null
       +}
       +
       +prev() {
       +        echo prev | nc $NCARGS $MPDHOST $MPDPORT > /dev/null
       +}
       +
       +stop() {
       +        echo stop | nc $NCARGS $MPDHOST $MPDPORT > /dev/null
       +}
       +
       +case "$1" in
       +        toggle) toggle;;
       +        next) next;;
       +        prev) prev;;
       +        stop) stop;;
       +        *) echo "usage: `basename $0` {toggle|next|prev|stop}";;
       +esac