Revised sed script for listing presets.
This commit is contained in:
parent
7e91229088
commit
a03d5d57a0
1 changed files with 10 additions and 8 deletions
18
wled
18
wled
|
@ -136,16 +136,18 @@ for wled_host; do
|
||||||
printf "loading ...\r"
|
printf "loading ...\r"
|
||||||
active_ps=$(active_preset "$wled_host")
|
active_ps=$(active_preset "$wled_host")
|
||||||
curl_fetch "http://$wled_host/presets.json" | \
|
curl_fetch "http://$wled_host/presets.json" | \
|
||||||
# Split into lines - one line per preset.
|
# Split into lines - one line per preset. Extract number and
|
||||||
sed --sandbox 's/"1\?[0-9]"[[:space:]]*:/\n&/g' | \
|
# name of every preset. Right-align numbers.
|
||||||
# Extract number and name of every preset. Right-align numbers.
|
sed --sandbox -n '
|
||||||
# Drop everything else.
|
s/"1\?[0-9]"[[:space:]]*:/\n&/g
|
||||||
sed --sandbox -n \
|
:loop
|
||||||
'/^"\(1\?[0-9]\)"[[:space:]]*:.*"n"[[:space:]]*:[[:space:]]*"\([[:alnum:] _-]*\)".*$/{
|
/^"\(1\?[0-9]\)"[[:space:]]*:[^\n]*"n"[[:space:]]*:[[:space:]]*"\([[:alnum:] _-]*\)"[^\n]*/{
|
||||||
s//\1: \2/
|
s//\1: \2/
|
||||||
s/^[0-9]:/ &/
|
s/^[0-9]:/ &/
|
||||||
p
|
P
|
||||||
}' | \
|
}
|
||||||
|
s/^[^\n]*\n//
|
||||||
|
t loop' | \
|
||||||
# Sort.
|
# Sort.
|
||||||
sort -b -n | \
|
sort -b -n | \
|
||||||
# Prepend description and mark active preset.
|
# Prepend description and mark active preset.
|
||||||
|
|
Loading…
Reference in a new issue