summaryrefslogtreecommitdiff
path: root/get_lights.sh
blob: e1274cf238fee24fec51a07d6c5323cc0fcfbce9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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