diff --git a/wled b/wled index 16ec609..71d3343 100755 --- a/wled +++ b/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.