forked from akburg/elgatokeylight
-
Notifications
You must be signed in to change notification settings - Fork 0
/
autolights.sh
30 lines (20 loc) · 1.58 KB
/
autolights.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/bash
# Begin looking at the system log via the steam sub-command. Using a --predicate and filtering by the correct and pull out the camera event
log stream --predicate 'subsystem == "com.apple.UVCExtension" and composedMessage contains "Post PowerLog"' | while read line; do
# The camera start event has been caught and is set to 'On', turn the light on
if echo "$line" | grep -q "= On"; then
echo "Camera has been activated, turn on the light."
# Light 1 - change IP to your first lights IP
curl --location --request PUT 'http://192.168.86.40:9123/elgato/lights' --header 'Content-Type: application/json' --data-raw '{"lights":[{"brightness":40,"temperature":162,"on":1}],"numberOfLights":1}'
#Light 2 (remove if you only have 1 light), change IP to your second light
curl --location --request PUT 'http://192.168.86.38:9123/elgato/lights' --header 'Content-Type: application/json' --data-raw '{"lights":[{"brightness":40,"temperature":162,"on":1}],"numberOfLights":1}'
fi
# If we catch a camera stop event, turn the light off.
if echo "$line" | grep -q "= Off"; then
echo "Camera shut down, turn off the light."
#Light 1 - set to off
curl --location --request PUT 'http://192.168.86.40:9123/elgato/lights' --header 'Content-Type: application/json' --data-raw '{"lights":[{"brightness":40,"temperature":162,"on":0}],"numberOfLights":2}'
#Light 2 - set to off
curl --location --request PUT 'http://192.168.86.38:9123/elgato/lights' --header 'Content-Type: application/json' --data-raw '{"lights":[{"brightness":40,"temperature":162,"on":0}],"numberOfLights":2}'
fi
done