summaryrefslogtreecommitdiff
path: root/get_lights.sh
diff options
context:
space:
mode:
Diffstat (limited to 'get_lights.sh')
-rwxr-xr-xget_lights.sh17
1 files changed, 17 insertions, 0 deletions
diff --git a/get_lights.sh b/get_lights.sh
new file mode 100755
index 0000000..e1274cf
--- /dev/null
+++ b/get_lights.sh
@@ -0,0 +1,17 @@
+#!/usr/bin/env bash
+set -euo pipefail
+
+source functions.sh
+
+read_vars
+
+listing=$(hue_request resource/light | jq -r '.data.[] | .id + " " + .metadata.name')
+
+test -t 1 && echo >&2 -e "\x1B[4m(Write this listing to <lights.txt>.)\x1B[0m"
+
+echo "$listing"
+
+if [[ ! -t 1 ]]; then
+ echo >&2 "$(wc -l <<<"$listing") lights written:"
+ sed >&2 's/^[^ ]*/-/' <<<"$listing"
+fi