Compare commits
3 commits
f8bb69594c
...
654b7ff480
Author | SHA1 | Date | |
---|---|---|---|
654b7ff480 | |||
b764a46ded | |||
b69fad5068 |
1 changed files with 12 additions and 2 deletions
14
wled
14
wled
|
@ -13,6 +13,11 @@ VERSION="0.1.3"
|
||||||
exit_code=0
|
exit_code=0
|
||||||
host_list=
|
host_list=
|
||||||
|
|
||||||
|
# Shell specific options.
|
||||||
|
case "$(readlink /proc/$$/exe)" in
|
||||||
|
*/zsh) setopt SH_WORD_SPLIT ;;
|
||||||
|
esac
|
||||||
|
|
||||||
# Make the exit status of command pipelines the status of the last command
|
# Make the exit status of command pipelines the status of the last command
|
||||||
# with non-zero exit status - if supported by this shell.
|
# with non-zero exit status - if supported by this shell.
|
||||||
(set -o pipefail 2>/dev/null) && set -o pipefail
|
(set -o pipefail 2>/dev/null) && set -o pipefail
|
||||||
|
@ -70,10 +75,15 @@ current_brightness() {
|
||||||
sed -n 's/.*"state"[[:space:]]*:[[:space:]]*{[^}]*"bri"[[:space:]]*:[[:space:]]*\([0-9]\{1,3\}\).*/\1/p'
|
sed -n 's/.*"state"[[:space:]]*:[[:space:]]*{[^}]*"bri"[[:space:]]*:[[:space:]]*\([0-9]\{1,3\}\).*/\1/p'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if test $# -eq 0; then
|
||||||
|
print_help
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
# Parse instance argument and store hostnames.
|
# Parse instance argument and store hostnames.
|
||||||
while test $# -gt 0; do
|
while test $# -gt 0; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
""|-h|--help) # Missing instance parameter.
|
-h|--help)
|
||||||
print_help
|
print_help
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
|
@ -131,7 +141,7 @@ for wled_host in $host_list; do
|
||||||
api_resp=$(curl_send "{'ps':$1}" "http://$wled_host/json")
|
api_resp=$(curl_send "{'ps':$1}" "http://$wled_host/json")
|
||||||
;;
|
;;
|
||||||
l|list) # List presets.
|
l|list) # List presets.
|
||||||
printf "loading ...\r"
|
test -t 1 && printf 'connecting ...\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 newline in front of every preset slice.
|
# Insert newline in front of every preset slice.
|
||||||
|
|
Loading…
Add table
Reference in a new issue