Connect to Airpods and show battery status

Connect to Airpods and show battery status
CheckAirPods.json (2.2 MB)

I pulled together some scripts to create a button for the Airpods.

  • pressing the button connects or disconnects the airpods.
  • you will need to change the name to the name of your Airpods in the applescripts.

How it looks when not connected.

How it looks when connected.

The shellscript is from Duck:
Logo's are from the Noun project (Allen Wang).
Some of the other code I pulled together from some fora, can't really remember where tbh.

Hope it can be useful for some of you,


Thanks for this script. I really love it and I find it very useful!

While using this widget, I did find a small bug.

To replicate it:

  1. Have another bluetooth device connected (like a mouse or keyboard) and make sure it's before your AirPods on the bluetooth list.
  2. Have your AirPods second or third or anywhere after the first bluetooth device on the list and make sure it is not connected.
  3. The widget will display 'Not Connected' instead of 'x'.

I believe this is a bug with your logic in looping. It seems like the script hits the if statement on the third line here and returns checkBattery() because the bluetooth devices before the AirPods are Connected: Yes.

  repeat numberOfDevices times --loop through each devices checking for Connected string
  	if item counter of myList contains "Ivan's AirPods" then
  		if item counter of myList contains "Connected: Yes" then
  			return checkBattery()
  		else if item counter of myList contains "Connected: No" then
  			return " "
  			display dialog "Error Parsing" --this shouldn't happen
  		end if
  	end if
  	set counter to counter + 1
  end repeat

I don't have any experience writing Apple Script, but I might try to debug this on the weekend.

Found the fix. For anybody using this widget in the future, there are three strings you will need to change.

  • Replace the two occurrences of "Ivan's AirPods" with "Your AirPod Name"
  • Replace the one occurrence of "name:" with "You AirPod Name:"

Am I right to understand that this automatically connects the AirPods with the Mac?
If yes, I can't get it to work. When I click on it, all it does is to open the Bluetooth pane in the menubar.

1 Like

There's another instance of "Ivan's AirPods" in the AppleScript that is supposed to connect the AirPods automatically. Expand the settings for the trigger and edit the name "Ivan's AirPods" to your appropriate name and then it should work.

I found two. I replaced them. Anything elsw that needs to change?

What happens is it simply opens the context menu of the menubar for the Bluetooth icon. And that‘s it.

The third instance I’m talking about is in the trigger settings, accessed from the cog wheel settings icon to the right of the drop-down menu where you choose what the button does when it is pressed (should say “Run Apple Script (blocking)”). Different window from the two instances you already replaced.

Oh, you are right. I did not see that. It now works. Thank you so much!

Connect to Airpods_v2.json (2.2 MB)

I am happy that it was useful for you! I cleaned the code a little bit in the shell-script part, and removed some funny loops. Explanation: the display of the battery level is like this: 5% - 10%, where the first percentage represents the case, and the second one of the earpods -- trying to keep the button as small as possible.

this version isnt working for me

Hi guys,
Is there any possibilities to get the batteries in two lines, one above the other (a bit like the music widget, playing Gorillaz right now)?

My bar gets a little full, and I'd like to be the AirPods Widget as small as possible actually, but still always present :wink: Thanks !!

1 Like

Bringing this up again. Unfortunately my abilities of coding aren't good enough to do this myself, but a script finishing like

set LeftAirPod to "L: " & word 1 of Battery & "%"
set RightAirPod to "R: " & word 2 of Battery & "%"
return LeftAirPod & "
" & RightAirPod

At lest something like this works in a Preset for the Fan rpm, the result looks like this.
Any ideas?


Echoing this! I tried to take a look, I have no idea how this code works but would love to stack it. Also my case doesn't show up in the battery meter?

Sorry, I'm just new BTT guy. How could I import/use this json to my BTT?


Download it. In BTT, navigate to the top right corner → presets → import → and navigate to The json

This discussion is heavily outdated though. If you're using Catalina there's a high risk that this won't work anymore. Give it a try though, and if it doesn't work I have another link for you! :slightly_smiling_face:

Sorry for the late reply, Cali.

I tried the v2 json. Too bad, it doesn't work on Catalina.

Any news?

Thanks :blush:

I could offer you the Widget used by myself for the PHoeNiX Preset, @yuuiko in AquaTouch, and (I think) @GoldenChaos in his homonymous preset.

Basically it will display your AirPods' battery levels one above the other, we all got rid of the battery level of the Case (I think though @K2DesignLab has a preset with all three values, I just don't find the link anymore…).

Here is the widget: AirPods Widget.json (63.7 KB)
Here is the trigger: Reset AirPods Widget.json (1.8 KB)

Import both .json files just like you did before (the trigger will appear in the triggers section don't worry if you don't see it the Touch Bar). Hold the widget in the TouchBar and write your AirPods name when asked (important: if you use the standard name like Wao's AirPods don't type it, but paste it from the System Settings → Bluetooth section - for any reason the ' used by apple is some other odd special character we didn't figure out yet).
Last but not least, check in BTT and give the widget the option to connect to your AirPods when hit :slightly_smiling_face: Voilà!

1 Like

@Caliguvara Something like this?

return "L " & batteryPercentLeft & "
" & "R " & batteryPercentRight
return "Not" & "
" & "Connected"

Exactly :wink: your preset is the only one that I remember that shows the battery percentage of the case too. :wink:

Imprint | Privacy Policy