Sort list of presets.
This commit is contained in:
parent
80d5972f80
commit
4bdafb7f2e
1 changed files with 5 additions and 3 deletions
8
wled
8
wled
|
@ -98,8 +98,8 @@ case "$2" in
|
|||
printf "loading ...\r"
|
||||
active_ps=$(active_preset "$wled_host")
|
||||
curl_cmd "http://$wled_host/presets.json" | \
|
||||
# Split into lines - one line per preset. Append final newline.
|
||||
sed --sandbox 's/"\(1\?[0-9]\)"[[:space:]]*:/\n&/g; $a\ ' | \
|
||||
# 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.
|
||||
|
@ -108,7 +108,9 @@ case "$2" in
|
|||
-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'
|
||||
-e '/^[1 ]\?[0-9]: [[:print:]]\+/p' | \
|
||||
# Sort.
|
||||
sort -b -n
|
||||
exit $?
|
||||
;;
|
||||
dump) # Dump JSON response from API.
|
||||
|
|
Loading…
Reference in a new issue