Switch to your Airpods from the command line

Sun Mar 31 2019 16:07:41 GMT+0200 (Central European Summer Time)

Wouldn’t it be cool if you could just write a command in your terminal and switch to your AirPods instead of having to use the Menubar Bluetooth menu or the Sound Icon.

We can install a cli that can control Bluetooth with brew.sh

$ brew install bluetoothconnector

Then we can connect to your Airpods by using:

$ BluetoothConnector -c MAC-ADDRESS --notify

We can find our airpods mac address by running:

$ system_profiler SPBluetoothDataType

Look for your AirPods name and copy the address:

Mine is an example: 8C-04-D0-96-55-CC

Then now we can do

$ BluetoothConnector -c 8C-04-D0-96-55-CC --notify

And you should see your Airpods connected, and if you run it again it will say Already connected.

Quick bash function

The mac address will never change, so we can make a small bash function and place it inside our bash config:

Here when the function is static we can use an alias

alias airpods="BluetoothConnector -c 7C-04-D0-96-55-BB --notify"

or if function looks like this

airpods() { BluetoothConnector -c 7C-04-D0-96-55-BB --notify }

and then you can simply reload your bash terminal and run

$ airpods

Success! No more fiddling with any gui!

Originally published at www.kevinsimper.dk.

Written by

I really like building stuff with React.js and Docker and also Meetups ❤

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store