This site runs best with JavaScript enabled.

Google Meet - On Air Light Automation

Photo by OCV PHOTO on Unsplash


How and why I set up my desk lamp to turn on automatically whenever I'm in a virtual meeting.

These days I tend to spend a lot of my time in Google Meet meetings. I recently created some automated tools to address a couple of problems.

The problems:

  1. I work from home (even before COVID-19). I have a wife and 5 kids. My office has glass doors. My family often wonders when it is safe to come to talk to me, or when I’m in a meeting. I need a reliable way to let them know when I’m in an online meeting.
  2. I have a window in my office that lets in a lot of light. Due to the placement of my workstation, my face is often too dark to see in webcam videos.

I’ve tried a few options to solve both of these issues. With number 1, I’ve tried using the door (open vs. shut) to indicate meetings. I’ve tried using a remote-controlled LED light to indicate it. Both had problems. I forget to open or close the door or turn the light on and off. Then there were the battery problems with the lights. My kids kept playing with them, etc.

With number 2, I’ve tried some camera lights to help light up my face. But the latest one I tried wasn’t bright enough, and the batteries would die within 30 minutes.

Now, for a better solution… I’ve been using this for only a day so far, but already I’m liking it much better. It could use some refining, but right now, it works.

Here is a high-level flowchart of how things work:

Flow diagram

Hardware needed:

Getting Tab URLs

I found this AppleScript online that will return all the URLs from all the tabs that are open from various browser windows. I use Brave Browser, so I have modified the script accordingly.

1# shows all urls open in Brave
2set urlList to ""
3
4if application "Brave Browser" is running then
5 tell application "Brave Browser"
6 set window_list to every window
7 repeat with the_window in window_list
8 set tab_list to every tab in the_window
9 repeat with the_tab in tab_list
10 set the_url to the URL of the_tab
11 set urlList to urlList & the_url & "\n"
12 end repeat
13 end repeat
14 end tell
15end if

Bash Script

I had a few iterations of this script. I started in Python, then moved to node.js. Finally, I decided to just write something more simple in bash.

1#!/bin/bash
2
3# be sure to set global env var IFTTT_MAKER_KEY
4export MEET_ON_AIR=new
5
6function get_tabs () {
7 local tabs=$(osascript tabs.osa)
8 # echo $tabs
9 local pattern="https:\/\/meet\.google\.com"
10 if [[ $tabs =~ $pattern ]] ; then
11 echo "found"
12 else
13 echo "nomeet"
14 fi
15}
16
17function check_meet () {
18 local found=$(get_tabs)
19 local trigger=0
20
21 if [[ $found == "found" ]] ; then
22 if [[ $MEET_ON_AIR != "on" ]] ; then
23 echo "Turning on the light"
24 MEET_ON_AIR=on
25 trigger=1
26 fi
27 else
28 if [[ $MEET_ON_AIR != "off" ]] ; then
29 echo "Triggering light out"
30 MEET_ON_AIR=off
31 trigger=1
32 fi
33 fi
34
35 if [[ $trigger == 1 ]] ; then
36 local url="https://maker.ifttt.com/trigger/meet-$MEET_ON_AIR/with/key/$IFTTT_MAKER_KEY"
37 curl -X POST $url
38 fi
39}
40
41while :;
42 do
43 check_meet
44 sleep 5
45done

Keeping It Running

I created a launchd script. I started with this nice tool and eventually bought a nifty little app called LauchControl that helped me better understand launchd. Here is my plist.

1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3<plist version="1.0">
4<dict>
5 <key>EnvironmentVariables</key>
6 <dict>
7 <key>IFTTT_MAKER_KEY</key>
8 <string>[MAKER_KEY_HERE]</string>
9 </dict>
10 <key>KeepAlive</key>
11 <dict/>
12 <key>Label</key>
13 <string>com.redseam.launchd.meet-on-air</string>
14 <key>Program</key>
15 <string>[FULL_PATH_TO]/meet-on-air.sh</string>
16 <key>RunAtLoad</key>
17 <true/>
18 <key>WorkingDirectory</key>
19 <string>[PATH_TO_DIR_WITH_APPLESCRIPT]</string>
20</dict>
21</plist>

IFTTT Automation

Part of the reason I switched from Python to Node was that I was looking for a way to control a Smart Life plug I had available. There was a node API wrapper for it. As I started going down that rabbit hole I realized it would be much easier to just use IFTTT.

I already had an IFTTT account with a maker webhook configured, so I just used that. Basically, once you have an account, you can go to https://ifttt.com/maker_webhooks/settings and it will show you the URL your webhook key. You can then go to https://maker.ifttt.com/use/ to test it out. The {event} key string that you use in the URL will be the one you use to trigger off of in your IFTTT Applet.

IFTTT Applets

The Applet is pretty straight forward. You will need to make sure you are connected to the Smart Life service. Basically, there are two Applets. The first one looks for the web request event name meet-on and turns on my outlet. The second one looks for the event meet-off and turns off the outlet.

That’s it!

Now, when I open a Google Meet window or tab, within a few seconds my lamp turns on. When I close the tab, the lamp turns off.

Working GIF

Discuss on TwitterEdit post on GitHub

Share article
Dustin Davis

Dustin Davis is a software engineer, people manager, hacker, and entreprenuer. He loves to develop systems and automation. He lives with his wife and five kids in Utah.

Join the Newsletter



Dustin Davis