The Shining Path of Least Resistance


Automatic Wi-Fi Switching Based on Running Applications in OSX

Posted by mattray on August 11, 2015

I’ve been a longterm user and big fan of the program ControlPlane, which uses information from the environment around you (attached devices, location, networks, etc.) to change configurations in response. In my own usage, I change Time Machine backup drives based on which networks I’m on and use it to automatically start a handful of applications when I get to work (Emacs, Slack, etc.).


At my current office I have a pretty poor Internet setup because we’re subleasing and don’t have a permanent connection. I’m using a Clear Wireless modem that gets about 10/1Mb/s down/up which is usually fine except for the fact that I’m now sharing the bandwidth with coworkers and Sprint is actively taking down the WIMAX network as they phase out this service. Luckily one of my coworkers has a MIFI puck that does a speedy 20/4Mb/s, but it’s not an unlimited data plan like the Clear modem.

The Problem

I do a lot of video conferencing and our current tool of choice is Zoom. Compared to the other tools we’ve used over the years, it’s really great but with the strain on our network I’ve been having a lot of pauses and stutters on the slower network.

The Solution

Unfortunately there’s not a built-in “Wi-Fi Network” option in ControlPlane, only Network Locations. Network Locations under the Network preference pane don’t allow you to have a single Wi-Fi network choice, so I looked elsewhere. It turns out you can change networks from the CLI, the actual command you use (originally found here) is:

networksetup -setairportnetwork en0 WIFI_SSID_I_WANT_TO_JOIN WIFI_PASSWORD

With that bit of knowledge I created a pair of shell scripts to switch between the two Wi-Fi options.

  • In the ControlPlane Preferences I added a new “Zoom” choice under Contexts.
  • Next I added “Running Application” as an Evidence Source.
  • Next I started up Zoom and under Rules selected “Add ‘Running Application Rule'” and choose “ (us.zoom.xos)” with the Context of “Zoom”.
  • Finally under Actions I added a pair of ShellScripts to be executed immediately when entering the “Office” and “Zoom” contexts when triggered.

The Result
The Internet is still pretty poor in my office, but now when I start up Zoom there’s a brief hiccup as the Wi-Fi switches over to the faster wireless provider. When I shut down Zoom I automatically switch back to the slower, unlimited bandwidth Clear network. Hopefully we’ll be getting a new office soon with a dedicated Internet connection with a lot more bandwidth, but this is a decent work-around in the meantime.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: