-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathonair.sh
More file actions
executable file
·17 lines (16 loc) · 797 Bytes
/
onair.sh
File metadata and controls
executable file
·17 lines (16 loc) · 797 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/bin/bash
# https://apple.stackexchange.com/questions/424789/can-i-trigger-a-homekit-scene-when-my-laptops-camera-is-turned-on-or-off
exec log stream | grep -E --line-buffered 'UVCAssistant' | # filter for UVCAssistant so BT stream is ignored
grep -E --line-buffered '(stop|start) stream' | # filter log events
# tee /dev/stderr | # output matching events for debugging
sed -Eu 's/.*(start|stop).*/\1/' | # reduce the log message down to a single word identifying the event/state
while read -r event; do # store that word in the $event variable
echo "Camera state has changed to: $event"
if [ "$event" = "start" ]; then
# echo "Keylight on"
keylight on
else
# echo "Keylight off"
keylight off
fi
done