From 4bdafb7f2e9e9b4710d5f0a4bcfb3d9999f406eb Mon Sep 17 00:00:00 2001 From: Shy Date: Mon, 5 Aug 2024 19:19:30 +0200 Subject: [PATCH] Sort list of presets. --- wled | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/wled b/wled index dd31534..16ec609 100755 --- a/wled +++ b/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.