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" | \
|
curl_cmd "http://$wled_host/presets.json" | \
|
||||||
# Split into lines - one line per preset.
|
# Split into lines - one line per preset.
|
||||||
sed --sandbox 's/"1\?[0-9]"[[:space:]]*:/\n&/g' | \
|
sed --sandbox 's/"1\?[0-9]"[[:space:]]*:/\n&/g' | \
|
||||||
# Prepend description, extract number and name of every preset,
|
# Extract number and name of every preset. Right-align numbers.
|
||||||
# match active preset, right-align numbers and finally select
|
# Drop everything else.
|
||||||
# lines to print.
|
|
||||||
sed --sandbox -n \
|
sed --sandbox -n \
|
||||||
-e "1i\\Presets on $wled_host:" \
|
'/^"\(1\?[0-9]\)"[[:space:]]*:.*"n"[[:space:]]*:[[:space:]]*"\([[:print:]]*\)".*$/{
|
||||||
-e 's/^"\(1\?[0-9]\)"[[:space:]]*:.*"n"[[:space:]]*:[[:space:]]*"\([[:print:]]*\)".*$/\1: \2/' \
|
s//\1: \2/
|
||||||
-e "s/^$active_ps:.*/& */" \
|
s/^[0-9]:/ &/
|
||||||
-e 's/^[0-9]:/ &/' \
|
p
|
||||||
-e '/^[1 ]\?[0-9]: [[:print:]]\+/p' | \
|
}' | \
|
||||||
# Sort.
|
# 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 $?
|
exit $?
|
||||||
;;
|
;;
|
||||||
dump) # Dump JSON response from API.
|
dump) # Dump JSON response from API.
|
||||||
|
|
Loading…
Reference in a new issue