From: Roman Bazalevsky Date: Fri, 30 Sep 2016 09:25:22 +0000 (+0300) Subject: Обработка команд увеличения/уменьшения громкости X-Git-Url: https://git.rvb.name/openhab-process.git/commitdiff_plain/662e5ab1419852189fcf45dcfd46fef5ef66cae9?ds=inline;hp=-c Обработка команд увеличения/уменьшения громкости --- 662e5ab1419852189fcf45dcfd46fef5ef66cae9 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 ;;