AirPods Pro battery info

Hey guys

How do i get AirPods Pro battery info? I am currently getting only the AirPods symbol . I am relatively new to this app and preset. Any help would be really appreciated

Long-press on the AirPods icon! It will open the Connectivity Strip which contains all the battery info for BT devices :slight_smile:

Hi, I can't get the battery info of the AirPods Pro

The storage of the information has changed in macOS Monterey. Since I did not install Golden Chaos (too much for me), I adapted the script "blindly". Try it once with this:

use framework "Foundation"
use framework "IOBluetooth"
use scripting additions

set processInfo to current application's NSProcessInfo's processInfo()'s operatingSystemVersion() as record
set pairedNames to ((current application's IOBluetoothDevice's pairedDevices())'s valueForKey:"nameOrAddress") as list
set connectedValue to ((current application's IOBluetoothDevice's pairedDevices())'s valueForKey:"connected") as list

set connectedDeviceName to ""
repeat with i from 1 to count pairedNames
	if item i of pairedNames contains "AirPods Pro" and item i of connectedValue = 1 then
		set connectedDeviceName to item i of pairedNames
	end if
end repeat

if connectedDeviceName ≠ "" then
	if processInfo's majorVersion > 11 then
		set xmlData to do shell script "system_profiler SPBluetoothDataType -xml"
		set theData to ((current application's NSString's stringWithString:xmlData)'s dataUsingEncoding:(current application's NSUTF8StringEncoding))
		set infoDict to (current application's NSPropertyListSerialization's propertyListWithData:theData options:0 format:(missing value) |error|:(missing value))
		set devlist to ((infoDict's valueForKey:"_items")'s firstObject()'s firstObject()'s valueForKey:"devices_list")
		repeat with j from 0 to (count of (devlist as list)) - 1
			if (devlist's objectAtIndex:j)'s allKeys()'s firstObject() as text = connectedDeviceName then
				set devDic to ((devlist's objectAtIndex:j)'s valueForKey:connectedDeviceName)
				set batteryPercentLeft to (devDic's valueForKey:"device_batteryLevelLeft")
				set batteryPercentRight to (devDic's valueForKey:"device_batteryLevelRight")
				if batteryPercentLeft ≠ missing value and batteryPercentRight ≠ missing value then
					set batteryPercentLeft to (batteryPercentLeft's substringToIndex:((batteryPercentLeft's |length| as integer) - 2)) as integer
					set batteryPercentRight to (batteryPercentRight's substringToIndex:((batteryPercentRight's |length| as integer) - 2)) as integer
					return "L: " & batteryPercentLeft & "%  " & "R: " & batteryPercentRight & "%"
				end if
			end if
		end repeat
		return ""
	else
		set batteryLevelLeft to do shell script "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=(\"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}\" ]] && OUTPUT=\"${OUTPUT}$(awk <<<\"${I}\")${!I}%\"; done; printf \"%s\" \"${OUTPUT}\"; else printf \"%s Not Connected\" \"${OUTPUT}\"; fi"
		set batteryLevelRight to do shell script "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=(\"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}\" ]] && OUTPUT=\"${OUTPUT}$(awk <<<\"${I}\")${!I}%\"; done; printf \"%s\" \"${OUTPUT}\"; else printf \"%s Not Connected\" \"${OUTPUT}\"; fi"
		set batteryPercentLeft to word 2 of batteryLevelLeft
		set batteryPercentRight to word 2 of batteryLevelRight
		return "L: " & batteryPercentLeft & "%  " & "R: " & batteryPercentRight & "%"
	end if
else
	return ""
end if

If it doesn't work, please post the current script once so I can possibly adjust it.

Thanks for your answer. I tried it just now, but it still can't work normally. Can you share you preset to me? My operation system is Big Sur.


Here is my script. I copy the script you posted.

I don't have a preset for that, just changed the script for Monterey. I use this one: Help with modifying some code pls - #16 by Dirk
It should have worked under Big Sur. Maybe the name of your AirPods does not contains "AirPods Pro". Have a look or maybe change this line in the script accordingly:

if item i of pairedNames contains "AirPods Pro" and item i of connectedValue = 1 then

OK, I'll try it. Thanks so much.