Skip to content

Instantly share code, notes, and snippets.

View ewiner's full-sized avatar
🥑
eat, sleep, PR

Eric Winer ewiner

🥑
eat, sleep, PR
  • Pagoda
  • New York City
View GitHub Profile
@ewiner
ewiner / onair.sh
Created January 31, 2023 18:03
Automatically sync an "on-air" light (using a Kasa smart plug) with a USB webcam
#!/bin/sh
cd "$(dirname "$0")"
export HOST=192.168.1.248
echo "Starting webcam monitor..."
poetry run kasa --host=$HOST state
log stream --predicate 'subsystem contains "com.apple.UVCExtension" and composedMessage contains "Post PowerLog"' \
| awk '$1 == "\"VDCAssistant_Power_State\"" {printf("poetry run kasa --type=plug --host=$HOST %s\n", substr(tolower($3),0,length($3)-1)) | "sh" }'

Keybase proof

I hereby claim:

  • I am ewiner on github.
  • I am ericw (https://keybase.io/ericw) on keybase.
  • I have a public key whose fingerprint is 6A41 A190 D9B2 CBF9 5654 CFBB 450F 6FA1 3D00 EFD8

To claim this, I am signing this object: