From 662e5ab1419852189fcf45dcfd46fef5ef66cae9 Mon Sep 17 00:00:00 2001 From: Roman Bazalevsky Date: Fri, 30 Sep 2016 12:25:22 +0300 Subject: [PATCH] =?utf8?q?=D0=9E=D0=B1=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=BA?= =?utf8?q?=D0=B0=20=D0=BA=D0=BE=D0=BC=D0=B0=D0=BD=D0=B4=20=D1=83=D0=B2?= =?utf8?q?=D0=B5=D0=BB=D0=B8=D1=87=D0=B5=D0=BD=D0=B8=D1=8F/=D1=83=D0=BC?= =?utf8?q?=D0=B5=D0=BD=D1=8C=D1=88=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=B3=D1=80?= =?utf8?q?=D0=BE=D0=BC=D0=BA=D0=BE=D1=81=D1=82=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- mqtt-mpd/mqmpd | 48 +++++++++++++++++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/mqtt-mpd/mqmpd b/mqtt-mpd/mqmpd index 9867146..5d378ea 100755 --- a/mqtt-mpd/mqmpd +++ b/mqtt-mpd/mqmpd @@ -60,24 +60,42 @@ do if [[ "$arg" =~ [A-Za-z0-9]+ ]] then + echo "$cmd -> $arg" + case $cmd in volume) - reply=( `$mpccmd volume`) - currvolume=`echo ${reply[1]} | sed 's/%//'` - if [ "$currvolume" ] + if [ "$arg" = "INCREASE" ] then - if [ "$arg" -gt "$currvolume" ] - then - delta=$(( $arg - $currvolume )) - $mpccmd volume +$delta - fi - if [ "$arg" -lt "$currvolume" ] + $mpccmd volume +5 + fi + if [ "$arg" = "DECREASE" ] + then + $mpccmd volume -5 + fi + if [[ "$arg" =~ [0-9]+ ]] + then + reply=( `$mpccmd volume`) + currvolume=`echo ${reply[1]} | sed 's/%//'` + if [ "$currvolume" ] then - delta=$(( $currvolume - $arg )) - $mpccmd volume -$delta - fi - fi + if [ "$arg" -gt "$currvolume" ] + then + delta=$(( $arg - $currvolume )) + $mpccmd volume +$delta + fi + if [ "$arg" -lt "$currvolume" ] + then + delta=$(( $currvolume - $arg )) + $mpccmd volume -$delta + fi + if [ "$arg" -eq "$currvolume" ] + then + $mpccmd repeat + $mpccmd repeat + fi + fi + fi ;; status) case $arg in @@ -94,6 +112,10 @@ do ;; esac ;; + currentnum) + $mpccmd pause + $mpccmd play $arg + ;; repeat|random|single|consume) $mpccmd $cmd $arg ;; -- 2.34.1