diff --git a/wled b/wled index c99a225..062dd35 100755 --- a/wled +++ b/wled @@ -86,13 +86,13 @@ case "$arg_inst" in esac # Parse and execute command argument against given instances. -while test $# -gt 0; do +for wled_host; do case "$arg_cmnd" in on) # Switch on. - api_resp=$(curl_send '{"on":true}' "http://$1/json") + api_resp=$(curl_send '{"on":true}' "http://$wled_host/json") ;; off) # Switch off. - api_resp=$(curl_send '{"on":false}' "http://$1/json") + api_resp=$(curl_send '{"on":false}' "http://$wled_host/json") ;; -b|--brightness) # Set brightness. if test -z "$arg_param"; then @@ -108,15 +108,15 @@ while test $# -gt 0; do echo "Error: parameter for brightness is out of range." >&2 exit 1 fi - api_resp=$(curl_send "{'bri':$bright}" "http://$1/json") + api_resp=$(curl_send "{'bri':$bright}" "http://$wled_host/json") ;; [1-9]|1[0-7]) # Switch to preset. - api_resp=$(curl_send "{'ps':$arg_cmnd}" "http://$1/json") + api_resp=$(curl_send "{'ps':$arg_cmnd}" "http://$wled_host/json") ;; l|list) # List presets. printf "loading ...\r" - active_ps=$(active_preset "$1") - curl_fetch "http://$1/presets.json" | \ + active_ps=$(active_preset "$wled_host") + curl_fetch "http://$wled_host/presets.json" | \ # Split into lines - one line per preset. sed --sandbox 's/"1\?[0-9]"[[:space:]]*:/\n&/g' | \ # Extract number and name of every preset. Right-align numbers. @@ -130,7 +130,7 @@ while test $# -gt 0; do # Sort. sort -b -n | \ # Prepend description and mark active preset. - sed --sandbox -e "1i\\Presets on $1:" \ + sed --sandbox -e "1i\\Presets on $wled_host:" \ -e "s/^ \?$active_ps:.*/& */" ;; "") # Missing command. @@ -155,7 +155,5 @@ while test $# -gt 0; do if test -n "$api_resp" && echo "$api_resp" | grep -qv '{\s*"success"\s*:\s*true\s*}'; then echo "Warning: unexpected responce from WLED API." >&2 fi - - shift done