[Sharing] One preset for ALL Apple wireless headphones (update to v1.1.1)

Github repo: GitHub - noonchen/BTT_AppleWirelessHeadphone: Toggle and display battery info of apple wireless headphones on the touch bar

This preset shows the icon and battery info of your Apple wireless headphones on the touch bar, it will support ALL apple headphones and furture modes, such as AirPods (Pro), BestsX, etc, as long as your macOS is up to date.

Note: Current for macos Catalina only, because Mojave and below do not have python3 installed and not image for AirPods Pro, I'd use python2 to rewrite the code sometime later.


You can use this preset to toggle up to 2 headphones.

  • Tap to toggle headphone #1
  • Long press to toggle headphone #2


Display demonstration:

Model Off On On
(one pod in case)
AirPods Pro
BeatsX -


Ensure that your headphone(s) appears on the Bluetooth panel of System Preferences.

  1. Download and double click AppleHeadphone.bttpreset to import it into BTT

  2. Go to Touch Bar section (⌘+1), click on the shell script/Tasks widget and change Launch Path to the output of which python3 in Terminal.

  3. Go to Named & Other Trigger section (⌘+9), find and expand the following triggers, Toggle...#1 is activated by tapping, and Toggle...#2 is by long pressing.

    Click on Run Real JavaScript and replace the selected string with the name of your device.


  • Then click on Action 2 and choose your device accordingly.


AppleHeadphone.bttpreset (10.0 KB)
AppleHeadphone_v1_0.bttpreset (Bug fixed)
AppleHeadphone_v1_1.bttpreset (Embed BTAudioSwitch)

AppleHeadphone_v1_1_1.bttpreset (Embed BTAudioSwitch, see change log in Github)

Thanks @Caliguvara for the inspiration!
For any issues/suggestions, please leave it in the comments or post an issue on Github. :wink:
If you like this preset, support me by: paypal.me/noonchen

Nice to see what you have done here :smiley: I might actually end up understand some basics of shell in order to adapt this to fit my Touch Bar Design :smiley: Thanks a lot for the work you did here!

Cool preset, it works - connects and disconnects my AirPods. But on the touchbar I get only this:

We're on it :wink:

Hi brayozz,

Line 77 is main() function, but I need to know the entire traceback info, can you show me the complete error message of this widget in BTT after clicking run script?

And, what macOS are you using?

@Caliguvara @brayozz Please try the preset I just fixed, it should be working now~

1 Like

It does :wink: Thanks!!

1 Like

hmm, me again, no icons, works kind of - weird

Hi tosbsas,

What version of macOS are you using? Mojave and below doesn’t have python3 natively, and no icons for products released later than the OS.

You can run the trigger in the BTT and attach the screenshot here.


Only get switching Text, no AirPodPro icons

Catalina latest update

It looks like there is a space in AirPods Pro in the scripts but not in the device name

yep was there, fixed it. Still no icons

Hi tosbsas,

Thanks for your screenshots, the message Error/Nothing was returned is ambiguous, it seems like the error is not from the python script, there are two reasons:

  1. This script should return some information if it runs, so it's not likely to return nothing.
  2. If any error occurs which my script is not well-handled, python will raise the error like the image below.

I guess the script is not even running, besides, I am able to reproduce your error when I change the python path in this text box to some non-existing path:
Thus, I highly recommend you to run which python3 in the terminal, and paste the result to the text box I show you.

If the method above is not working, download the script below (the content is the python code in my preset) and change the extension to .py, launch terminal and type python3 and a space, then drag the file to the terminal window and see if anything is returned.
Untitled.js (3.8 KB)
If any error occurs, pls inform me.

you nailed it, python3 in my case was at /usr/bin/python3

Got the icons now. Only thing left - what would be the NC color code for black as I have all my icons with black bg

Hi @jrosenkrantz,

I saw your request in another post that you want to hide the icon when the device is not connected, simply add this line of code
if not connected: return ""
in here:

It should do the trick.

Thank you Noon_Chen.. this worked brilliantly!
It's a beautiful widget you created

1 Like

Glad to hear the problem is solved.

What color do you want to change? The background color of the button or the color of the text?

BG color can be changed here:

If you'd like to change the font color, add/modify the code here:

The color value should be "R,G,B,A", representing Red, Green, Blue and Alpha (opaqueness), white would be "255,255,255,255", black would be "0,0,0,255"

I get an error message when putting

ile "", line 6
disconnectedBGColor = β€œ0,0,0,255"
SyntaxError: invalid character in identifier

β€œβ€ is the source of the issue, replace them to ""

whow, found it - wierd, never changed that "

Imprint | Privacy Policy