Compare commits

..

No commits in common. "39323d772afbfaec1f77d38820dd7b12ef38b659" and "d08e07fd72c2dfd5d4e94db11fe81189868cf397" have entirely different histories.

7
wled
View file

@ -38,9 +38,10 @@ curl_cmd() {
active_preset() { active_preset() {
# Find number of active preset. API returns -1 if none is active, we return # Find number of active preset. API returns -1 if none is active, we return
# an empty string. # an empty string.
curl_cmd "http://$1/json" | \ preset="$(curl_cmd "http://$1/json" | \
# -1 will be a no-match. # -1 will be a no-match.
sed -n 's/.*"ps"[[:space:]]*:[[:space:]]*\(1\?[0-9]\).*/\1/p' sed -n 's/.*"ps"[[:space:]]*:[[:space:]]*\(1\?[0-9]\).*/\1/p')"
printf '%u' "$preset"
} }
# Parse host argument. # Parse host argument.
@ -102,7 +103,7 @@ case "$2" in
# Extract number and name of every preset. Right-align numbers. # Extract number and name of every preset. Right-align numbers.
# Drop everything else. # Drop everything else.
sed --sandbox -n \ sed --sandbox -n \
'/^"\(1\?[0-9]\)"[[:space:]]*:.*"n"[[:space:]]*:[[:space:]]*"\([[:alnum:] _-]*\)".*$/{ '/^"\(1\?[0-9]\)"[[:space:]]*:.*"n"[[:space:]]*:[[:space:]]*"\([[:print:]]*\)".*$/{
s//\1: \2/ s//\1: \2/
s/^[0-9]:/ &/ s/^[0-9]:/ &/
p p