Does anyone have a working AirPods Pro widget that shows battery percentage and controls functions? I am running MacOS Ventura and cannot get any of the previously shared widgets to work. Any help would be greatly appreciated.
I've got the same problem.
Someone would need to adapt the widget on Ventura.
The best way to get the data is as follows:
set bluetoothData to do shell script "system_profiler SPBluetoothDataType -json"
The AppleScript already provides the correct values in a JSON structure (under "device_connected"):
…
"device_connected" : [
{
"Beoplay EX" : {
"device_address" : "00:09:A7:86:E6:0B",
"device_batteryLevelMain" : "100 %",
"device_minorType" : "Headset",
"device_services" : "0x802019 < HFP AVRCP A2DP Braille ACL >"
}
}
],
"device_not_connected" : [
…
With the AirPods, this is even done separately for left and right.
Unfortunately, I no longer have AirPods, since I switched to Bang & Olufsen, so I can not make the adjustments myself.
For anyone else following:
I spent the last 45 minutes going back and forth with my new openAI Plus subscription. Using chatGPT4, the following applescript/bash was created and it works great on my system (MacOS 13.4 Ventura.). NOTE: YOU MUST REPLACE 'shaferz AirPods Pro" below with your own airpods name
set bashCommand to "system_profiler SPBluetoothDataType | grep -A 20 'shaferz AirPods Pro:'"
try
set output to do shell script bashCommand
on error errMsg number errNum
set output to "Error: " & errMsg & " (" & errNum & ")"
end try
if output is not equal to "" then
set AppleScript's text item delimiters to {"\n"}
set batteryLevels to paragraphs of output
set leftBattery to missing value
set rightBattery to missing value
repeat with lineText in batteryLevels
if lineText contains "Left Battery Level" then
set leftBattery to last word of lineText
else if lineText contains "Right Battery Level" then
set rightBattery to last word of lineText
end if
end repeat
set AppleScript's text item delimiters to {""}
if leftBattery is missing value then
set leftBattery to "Off"
end if
if rightBattery is missing value then
set rightBattery to "Off"
end if
set BatteryLevel to "L: " & leftBattery
if leftBattery is not equal to "Off" then
set BatteryLevel to BatteryLevel & "%"
end if
set BatteryLevel to BatteryLevel & "
R: " & rightBattery
if rightBattery is not equal to "Off" then
set BatteryLevel to BatteryLevel & "%"
end if
else
set BatteryLevel to "L: Off
R: Off"
end if
return BatteryLevel
When one airpod pro is disconnected, that row will read as 'Off'. The only 'bug' I can find at this point is that at some point, Apple has made it so that when you put an airpod into the battery case, it does not immediately disconnect from my macbook. It remains 'connected' for 10-20 seconds. This is even evident in the top macos toolbar as well. Eventually, MacOS realizes that the airpod is put away and is no longer connected, but it isnt instant anymore like it used to be.
Does anyone else want to give this a try and see if it works for you?