Compare commits
No commits in common. "eb1e69e05dc89330b8d6dee5db24a7b3eb78d410" and "7e91229088e87026851f803563848f1ed202a653" have entirely different histories.
eb1e69e05d
...
7e91229088
1 changed files with 12 additions and 18 deletions
30
wled
30
wled
|
@ -136,27 +136,21 @@ 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" | \
|
||||||
# Insert newlines in front of every preset.
|
# Split into lines - one line per preset.
|
||||||
# Extract number and name of every preset.
|
sed --sandbox 's/"1\?[0-9]"[[:space:]]*:/\n&/g' | \
|
||||||
# Match and mark active preset.
|
# Extract number and name of every preset. Right-align numbers.
|
||||||
# Right-align numbers.
|
# Drop everything else.
|
||||||
# Print up to next newline, delete up to next newline.
|
sed --sandbox -n \
|
||||||
# Prepend description.
|
'/^"\(1\?[0-9]\)"[[:space:]]*:.*"n"[[:space:]]*:[[:space:]]*"\([[:alnum:] _-]*\)".*$/{
|
||||||
sed --sandbox -n '
|
|
||||||
s/"1\?[0-9]"[[:space:]]*:/\n&/g
|
|
||||||
:loop
|
|
||||||
/^"\(1\?[0-9]\)"[[:space:]]*:[^\n]*"n"[[:space:]]*:[[:space:]]*"\([[:alnum:] _-]*\)"[^\n]*/{
|
|
||||||
s//\1: \2/
|
s//\1: \2/
|
||||||
s/^'"$active_ps"':[^\n]*/& */
|
|
||||||
s/^[0-9]:/ &/
|
s/^[0-9]:/ &/
|
||||||
P
|
p
|
||||||
}
|
}' | \
|
||||||
s/^[^\n]*\n//
|
|
||||||
t loop
|
|
||||||
i\
|
|
||||||
'"Presets on $wled_host:" | \
|
|
||||||
# Sort.
|
# Sort.
|
||||||
sort -n -b -t : -k 1,1
|
sort -b -n | \
|
||||||
|
# Prepend description and mark active preset.
|
||||||
|
sed --sandbox -e "1i\\Presets on $wled_host:" \
|
||||||
|
-e "s/^ \?$active_ps:.*/& */"
|
||||||
;;
|
;;
|
||||||
"") # Missing command.
|
"") # Missing command.
|
||||||
echo "Error: missing command." >&2
|
echo "Error: missing command." >&2
|
||||||
|
|
Loading…
Add table
Reference in a new issue