AirPods battery display breaks onto two lines

Continuing the discussion from GoldenChaos-BTT Support and Feedback Thread:

hello your preset is wonderful! but i have a one problem..

my airpod is 2 generation. your airpod battery shows like this...

why this happen??

He has the same issue with my AirPods widget with setup UI.

(he PMd me)

Interesting - I will confirm this on my end and release a fix. I’m guessing something changed about the output of the Bluetooth shell script.

I should have time tomorrow and this weekend to put out a new experimental version :grimacing:

Hello, I'm new here. Just recently bought the new macbook & newer AirPods. I have tried all the versions that have been put on this website for the AirPods battery indicator widget and seem to run into the same problem with no solutions in sight. I'm assuming it's something to do with the newer AirPods as my older ones seem to connect correctly, but the AirPods 2 only show battery indicator of the Left side, else just says "false".

The name does not seem to be a conflict as they're copied over universally like a past user suggested. ("Danes AirPods")

Hey, I've installed BTT recently and was wondering if anyone has been able to fix this issue. I have the exact same problem (have AirPods 1 though). My GC preset is 3.202, here's a screenshot of my TouchBar.

Thanks in advance,
Cheers :slight_smile:

I'm working on fixing this + adding support for AirPods Pro. Due to a macOS bluetooth connection issue, I've been unable to connect any H1 chip devices since the AirPods v2 launch. However, the bug I reported was finally fixed in 10.15.1, and I can connect my AirPods again. So expect a release in the near future addressing AirPods!

2 Likes

For those of you with AirPods Pro - here's the icon I've made for the upcoming AirPods update :smiley:

AirPods%20Pro

And here's what it looks like on the Touch Bar:

17%20PM

You can replace the existing AirPods widget icon with this if you can't wait, and it will work with the blue color. However, I'll be adding some special code for AirPods Pro in the update that make the experience smoother!

2 Likes

And did you manage to work the script in a way to return only the battery level of the two AirPods? :wink:

1 Like

Looking forward to it. Thanks!

Working on it! :smiley:

1 Like

How fancy are you getting? :stuck_out_tongue: Just noticed that Catalina has this sweet menu when connected to Airpods Pro.

10_D0ycYQ

1 Like

I DEFINITELY want to support switching noise cancelling modes :smile:

1 Like

While I was tweaking the AirPods widgets, I realized the game controller icon is really out of date. I made a new one using the controller icon from Apple Arcade :slight_smile: I'm also adding xbox and DualShock controller support to the game controller connect button!

New icon for downloading:

game-controller

Also, I'm pretty sure I fixed the number display issue:

I'll work on adding the more compact display from the other AirPods thread once I've got everything working the way I want :slight_smile:

2 Likes

A pretty easy workaround could be just adding "& return &" after the return for L I actually had to do that anyway.

This is already done actually. But since Catalina, the script doesn't put out 2 values anymore, but 4, in a way I just don't get for now. Didn't manage yet to break it down on two lines or to retail's only lines containing a "%" to display. Don't know, maybe it will be easier just to read out the menu item from the Bluetooth Dropdown, would be way less smart though. Added to my post exam list.

could we text-edit the output and delete the two extra outputs with ApSc? Bandaid fix i know but well do we have anything else?

oh and I have no way of implementing that myself because I don’t have airpods and thus can’t get the glitched output :grimacing:

1 Like

This is what I was thinking about. Won't have time to check this out 'till next weekend, but then I'll have a look on it. It's way too annoying :roll_eyes:

Output (copy-paste from the Script Editor) looks like this:

19

94%

8

88%

The Script
return checkStatus()

on checkStatus()
	--GET STORED NAME
	tell application "BetterTouchTool"
		--attempt to get variable
		try
			set LclAirPodsName to get_string_variable "AirPodsWg_DevceName"
		end try
	end tell
	--END GET STORED NAME
	
	--set myString to button returned of (display dialog "Connected?" buttons {"Yes", "No"})
	--set myString to "name: DR-BT101 Connected: " & myString
	
	(*uncomment line below when done testing*)
	set myString to do shell script "system_profiler SPBluetoothDataType"
	
	--initial check if it's not even there
	if myString does not contain LclAirPodsName then
		return " "
	else
		
		--find out if connected/disconnected
		set AppleScript's text item delimiters to "name:"
		set myList to the text items of myString --each item of mylist is now one of the devices
		
		set numberOfDevices to count of myList
		set counter to 1
		repeat numberOfDevices times --loop through each devices checking for Connected string
			if item counter of myList contains LclAirPodsName then
				if item counter of myList contains "Connected: Yes" then
					return checkBattery()
				else if item counter of myList contains "Connected: No" then
					return " "
				else
					display dialog "Error Parsing" --this shouldn't happen
				end if
			end if
			set counter to counter + 1
		end repeat
	end if
end checkStatus

on checkBattery()
	set OUTPUT1 to do shell script "
OUTPUT1='';
BLUETOOTH_DEFAULTS=$(defaults read /Library/Preferences/com.apple.Bluetooth);
SYSTEM_PROFILER=$(system_profiler SPBluetoothDataType); 
MAC_ADDR=$(grep -b2 \"Minor Type: Headphones\"<<<\"${SYSTEM_PROFILER}\"|awk '/Address/{print $3}'); 
CONNECTED=$(grep -ia6 \"${MAC_ADDR}\"<<<\"${SYSTEM_PROFILER}\"|awk '/Connected: Yes/{print 1}'); 
BLUETOOTH_DATA=$(grep -ia6 '\"'\"${MAC_ADDR}\"'\"'<<<\"${BLUETOOTH_DEFAULTS}\"); 
BATTERY_LEVELS=(\"BatteryPercentCombined\" \"HeadsetBattery\" \"BatteryPercentSingle\" \"BatteryPercentRight\"); 

if [[ \"${CONNECTED}\" ]];
 then 
 for I in \"${BATTERY_LEVELS[@]}\";
  do 
  declare -x \"${I}\"=\"$(awk -v pat=\"${I}\" '$0~pat{gsub (\";\",\"\"); print $3}'<<<\"${BLUETOOTH_DATA}\")\";
   [[ ! -z \"${!I}\" ]] && 
   OUTPUT1=\"${OUTPUT}$(awk '/BatteryPercent/{print substr($0)}'<<<\"${I}\")${!I}%\";
    done;
    printf \"%s\" \"${OUTPUT1}\";
fi"
	
	set OUTPUT2 to do shell script "
OUTPUT2='';
BLUETOOTH_DEFAULTS=$(defaults read /Library/Preferences/com.apple.Bluetooth);
SYSTEM_PROFILER=$(system_profiler SPBluetoothDataType); 
MAC_ADDR=$(grep -b2 \"Minor Type: Headphones\"<<<\"${SYSTEM_PROFILER}\"|awk '/Address/{print $3}'); 
CONNECTED=$(grep -ia6 \"${MAC_ADDR}\"<<<\"${SYSTEM_PROFILER}\"|awk '/Connected: Yes/{print 1}'); 
BLUETOOTH_DATA=$(grep -ia6 '\"'\"${MAC_ADDR}\"'\"'<<<\"${BLUETOOTH_DEFAULTS}\"); 
BATTERY_LEVELS=(\"BatteryPercentCombined\" \"HeadsetBattery\" \"BatteryPercentSingle\" \"BatteryPercentLeft\"); 

if [[ \"${CONNECTED}\" ]];
 then 
 for I in \"${BATTERY_LEVELS[@]}\";
  do 
  declare -x \"${I}\"=\"$(awk -v pat=\"${I}\" '$0~pat{gsub (\";\",\"\"); print $3}'<<<\"${BLUETOOTH_DATA}\")\";
   [[ ! -z \"${!I}\" ]] && 
   OUTPUT2=\"${OUTPUT}$(awk '/BatteryPercent/{print substr($0)}'<<<\"${I}\")${!I}%\";
    done;
    printf \"%s\" \"${OUTPUT2}\";
fi"
	
	set BatteryLevel to OUTPUT2 & "
" & OUTPUT1
	
	if BatteryLevel is "" & "
" & "" then
		return " "
	else
		return BatteryLevel
	end if
	
end checkBattery

--thanks to @yyuuiko for the base of the code!

1 Like

So the desired output is the 94% and 88% right?

1 Like

Yupp. :+1:t4:

1 Like

I fixed this in my script by setting the variable to word 2 of the output and adding the percent symbol back in after the fact. :slight_smile:

1 Like
Imprint | Privacy Policy