I am trying to check the battery level of my wireless headphones from the command line. I came across a few discussions, and it seems all I need to do is enter the following:
ioreg -c 'deviceName' |grep -i batterypercent
I tried this command using "Powerbeats Wireless" and "bluetoothaudiod" for the 'deviceName'
's, but neither returned the batterypercent
. I tried ioreg -c bluetoothaudiod |grep -i battery
to get general information about the battery, and get this as a response:
| | +-o AppleSmartBatteryManager <class AppleSmartBatteryManager, id 0x100000250, registered, matched, active, busy 0 (0 ms), retain 7>
| | +-o AppleSmartBattery <class AppleSmartBattery, id 0x100000252, registered, matched, active, busy 0 (0 ms), retain 6>
If I connect the headphones to my iPhone, the battery level immediately pops up on the toolbar. This leads me to believe that the device is broadcasting battery level, and that I should be able to access this information from my computer.
How can I check the battery level of my bluetooth connected headphones?
Edit:
Initially I thought the issue was with the device name, but it seems "Powerbeats Wireless"
and bluetoothaudiod
work interchangeably. Just can't figure out how to access the batterypercent
param.
Edit 2:
Looking at the Bluetooth docs, it seems there's a Battery Service which exposes the Battery State and Battery Level. The Battery Level can be read using the GATT Read Characteristic Value sub-procedure, so I need to figure out a way of interfacing with this service from the command line. I have a feeling batterypercent
may only be coded for standard peripherals (trackpad, mouse, keyboard), as all battery monitoring widgets I've tried are only compatible with such devices.
Edit 3:
Revisiting this almost a year later. I know have a wireless trackpad & keyboard, and can see their battery levels perfectly fine ( in both the toolbar or the command line). Still unable to get the battery level from my headphones though, and not sure why :/
ioreg -c "Powerbeats Wireless" |grep -i battery
also returns the general battery info, so i think i have the correct device name. But why is thebatterylevel
command not working !! Smh