tminimpc - scripts - random scripts
 (HTM) git clone https://git.parazyd.org/scripts
 (DIR) Log
 (DIR) Files
 (DIR) Refs
       ---
       tminimpc (881B)
       ---
            1 #!/bin/sh
            2 #
            3 # parazyd - (c) wtfpl 2016
            4 # rudimentary mpd controls
            5 
            6 MPDHOST=${MPDHOST:-"/home/parazyd/.config/mpd/mpd.sock"}
            7 # MPDHOST=${MPDHOST:-"127.0.0.1 6600"}
            8 
            9 if [ $MPDHOST == /* ] || [ $MPDHOST == ~/* ]; then
           10         NCARGS="-U"
           11 else
           12         NCARGS=""
           13 fi
           14 
           15 toggle() {
           16         playing() {
           17                 echo status | busybox nc $NCARGS $MPDHOST | grep "^state: play$"
           18         }
           19 
           20         play() {
           21                 echo play | busybox nc $NCARGS $MPDHOST > /dev/null
           22         }
           23 
           24         pause() {
           25                 echo pause | busybox nc $NCARGS $MPDHOST > /dev/null
           26         }
           27 
           28         test -z "$(playing)" && play || pause
           29 }
           30 
           31 next() {
           32         echo next | busybox nc $NCARGS $MPDHOST $MPDPORT > /dev/null
           33 }
           34 
           35 prev() {
           36         echo prev | busybox nc $NCARGS $MPDHOST $MPDPORT > /dev/null
           37 }
           38 
           39 stop() {
           40         echo stop | busybox nc $NCARGS $MPDHOST $MPDPORT > /dev/null
           41 }
           42 
           43 case "$1" in
           44         toggle) toggle;;
           45         next) next;;
           46         prev) prev;;
           47         stop) stop;;
           48         *) echo "usage: `basename $0` {toggle|next|prev|stop}";;
           49 esac