Skip to content

Instantly share code, notes, and snippets.

@dnnsmnstrr
Last active May 15, 2022 17:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dnnsmnstrr/37b84f69773c772d0778373ccefbe3a1 to your computer and use it in GitHub Desktop.
Save dnnsmnstrr/37b84f69773c772d0778373ccefbe3a1 to your computer and use it in GitHub Desktop.
Shell script to react to the state of a webcam in macOS Monterey
log stream --predicate 'subsystem contains "com.apple.UVCExtension" and composedMessage contains "Post PowerLog"' --style ndjson | while read LOGLINE
do
echo ${LOGLINE} | grep -q '"VDCAssistant_Power_State" = Off' && WEBCAM_STATE='Off'
echo ${LOGLINE} | grep -q '"VDCAssistant_Power_State" = On' && WEBCAM_STATE='On'
echo ${WEBCAM_STATE}
done
@dnnsmnstrr
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment