On-Air: Better Coworking at Home
TL;DR: I made a thing! When my Mac camera is on (presumably because I'm in a meeting), an "On Air" light turns on. This should make co-working at home (between a software engineer and a domestic engineer) much easier.
My home "office" is current co-located with our bedroom. On multiple occasions this week alone, my wife poked her head in during a video call, sheepishly closing the door after discovering me in my mid-morning standup.
This week was different: rather than continuing to chuckle each time it happens, I decided to make use of the growing pile of microcontrollers on my desk and make an Internet-connected "on-air" light.
The microcontroller I chose is the Electric Imp (specifically the imp001). I first considered a custom build with an April board, but decided to use the Hannah instead and build a custom case instead (the unused knob is a bit of an eyesore, but it's significantly easier this way). One cardboard box, a pair of scissors, and some masking tape later, and I had my case. I made a little window in the box for the RGB LED to shine through, covering up the window with a small piece of paper with "ON AIR" written on it.
Since I used an Imp, I took advantage of their excellent community and grabbed some code for the I2C and IO Extender from GitHub, and the rest of the Agent/Device code was incredibly simple. In the end, I had a single URL I could hit to turn the LED on and off:
agent.electricimp.com/DEVICE_ID?led=$STATE. This was my original goal: to be able to turn the light on and off from my desk.
Fortunately, that evening was the monthly Bellingham Codes meetup. Talking about my little project with the group, another attendee had a great idea: even if writing plugins for each video conferencing platform would be overly complicated, I could write a script to detect if the camera is in use, and trigger the light entirely based on that.
My first instinct to check camera state was Objective-C, and I spent a few hours to that effect. As it turns out, using a generalized search engine to find sample Obj-C code for detecting the camera state was impossible. Browsing StackOverflow directly, less so. However, I discovered something even better: other solutions to the same problem. While browsing the osx tag, I found this post discussing Chrome's use of the camera. It turns out the camera device shows up via
lsof, so I had my hook.
I published the resulting code on GitHub, though it is certainly Mac-only. Let me know what you think!