Revised list pipeline.
This commit is contained in:
parent
4bdafb7f2e
commit
d08e07fd72
1 changed files with 11 additions and 9 deletions
20
wled
20
wled
|
@ -100,17 +100,19 @@ case "$2" in
|
|||
curl_cmd "http://$wled_host/presets.json" | \
|
||||
# Split into lines - one line per preset.
|
||||
sed --sandbox 's/"1\?[0-9]"[[:space:]]*:/\n&/g' | \
|
||||
# Prepend description, extract number and name of every preset,
|
||||
# match active preset, right-align numbers and finally select
|
||||
# lines to print.
|
||||
# Extract number and name of every preset. Right-align numbers.
|
||||
# Drop everything else.
|
||||
sed --sandbox -n \
|
||||
-e "1i\\Presets on $wled_host:" \
|
||||
-e 's/^"\(1\?[0-9]\)"[[:space:]]*:.*"n"[[:space:]]*:[[:space:]]*"\([[:print:]]*\)".*$/\1: \2/' \
|
||||
-e "s/^$active_ps:.*/& */" \
|
||||
-e 's/^[0-9]:/ &/' \
|
||||
-e '/^[1 ]\?[0-9]: [[:print:]]\+/p' | \
|
||||
'/^"\(1\?[0-9]\)"[[:space:]]*:.*"n"[[:space:]]*:[[:space:]]*"\([[:print:]]*\)".*$/{
|
||||
s//\1: \2/
|
||||
s/^[0-9]:/ &/
|
||||
p
|
||||
}' | \
|
||||
# Sort.
|
||||
sort -b -n
|
||||
sort -b -n | \
|
||||
# Prepend description and mark active preset.
|
||||
sed --sandbox -e "1i\\Presets on $wled_host:" \
|
||||
-e "s/^ \?$active_ps:.*/& */"
|
||||
exit $?
|
||||
;;
|
||||
dump) # Dump JSON response from API.
|
||||
|
|
Loading…
Reference in a new issue