Last active
April 26, 2022 05:33
-
-
Save auxesis/63895288640e4718b45dc72ac742e143 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
HOME_NETWORK_NAME="MI WIFI SU WIFI" | |
function currentWifiNetworkName() { | |
/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I | awk -F: '($1 ~ "^ *SSID$"){print $2}' | cut -c 2- | |
} | |
log stream --predicate 'subsystem contains "com.apple.UVCExtension" and composedMessage contains "Post PowerLog"' | | |
while read event; do | |
power_state=$(echo $event | grep VDCAssistant_Power_State) | |
if [ -n "$power_state" ]; then | |
if [ "$(currentWifiNetworkName)" != "${HOME_NETWORK_NAME}" ]; then | |
echo "Not at home, so not changing lights." | |
continue | |
fi | |
state="$(echo $power_state | awk '{ $2 ; gsub(/;$/,"") ; print $3}')" | |
case $state in | |
On) | |
echo "Camera On: changing light to red" | |
shortcuts run "I am on a video call" & | |
;; | |
Off) | |
echo "Camera Off: changing light to purple" | |
shortcuts run "I am off a video call" & | |
;; | |
*) | |
echo "Should not have reached here!" | |
exit 1 | |
;; | |
esac | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment