36

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 :/

6
  • 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 the batterylevel command not working !! Smh
    – 0xPingo
    Nov 11, 2015 at 19:39
  • Please edit your question instead of commenting on your own question.
    – At0mic
    Nov 11, 2015 at 19:46
  • @IronCraftMan edits are now complete. You think you could offer any help?
    – 0xPingo
    Nov 11, 2015 at 20:03
  • Hi - I'm interested in hearing if you got any further. I want to get the battery life out of PS4 controllers connected by BlueTooth to my iMac.
    – dunxd
    Mar 4, 2016 at 10:33
  • 1
    Doesn't work for my JVC bluetooth headphones either. Strange, because my 5-year-old iPhone 4S has no problem telling me their battery level when connected.
    – John Smith
    Apr 11, 2017 at 1:07

5 Answers 5

14

On my iMac(macOS 10.12.6), none of solutions mentioned above works. After reading the man page of ioreg. The solution that works on my computer is:

// the -r option is used to reduce output
// the -l option is used to display properties for all object
// by default some object properties are not shown
// the -c specify device class, the class could be specific or general
ioreg -c AppleDeviceManagementHIDEventService -r -l
ioreg -c AppleDeviceManagementHIDEventService -r -l | grep -i battery

// instead of using device io class, you could also use a property key to query
// you need to know one of target device's property key(-k), for example it is BatteryPercent for Bluetooth keyboard and mouse
// any device with this property will be listed
ioreg -r -l -k "BatteryPercent"
ioreg -r -l -k "BatteryPercent" | grep -i battery

There are some other device classes to try for the -c argument: AppleHSBluetoothDevice AppleHSBluetoothHIDDriver AppleMultitouchMouseHIDEventDriver AppleHIDKeyboardEventDriverV2, they give different output.

10

None of the answers works for me.

This app works for me:

https://github.com/jariz/Akku/ (note: this tool is no longer being actively worked on and won't work in Monterrey or later)

It is open-source and free.

Remember to download version 0.1.0-beta.10.

enter image description here

5
  • 2
    Been looking for an app like this for a while. Thanks a lot! Apr 28, 2020 at 19:09
  • Currently, notifications have a problem. Apart from that, I tested on 2 devices & it worked perfectly. :) Jun 3, 2020 at 8:49
  • Worked for me with JBL T460BT. Thanks. Jul 8, 2020 at 17:36
  • Nice app, but didn't work with QC 35 II :( (no reported battery state...)
    – levsa
    Aug 31, 2020 at 9:25
  • My headphones don't report battery status without it being explicitly requested, and this app doesn't request it. I had to connect my headphones to my phone as well so it can give out a report, and this app DID intercept it and show it. Jan 16, 2021 at 14:52
9

You need to use ioreg. You'll need to know the name of the device. Just follow this guide.

The guide, in short, basically has you run the ioreg -c <devicename> |grep '"BatteryPercent" ='

Example:

ioreg -c BeatsBluetoothHeadset |grep '"BatteryPercent" ='

enter image description here

Additionally, you could retrieve broader battery information with:

ioreg -c BeatsBluetoothHeadset |grep Battery
3
  • 2
    Hey, thanks for your response! This problem seems to be specific to the Beats headphones, as I can access battery levels for my wireless keyboard & trackpad. Will update the original question!
    – 0xPingo
    Aug 16, 2016 at 17:49
  • 1
    it's not working for me Jun 2, 2017 at 15:24
  • 3
    That guide isn't telling us how to find the name of the device. Mar 17, 2020 at 7:34
2

I just discovered that to check the battery level of my powerbeats 3 on my Mac I just go to the bluetooth menu in the icon area in the top right of the screen, hover over your connected powerbeats and then it shows the battery level right there. Hope that helps.

0

This set of flags boils down the output to the minimum and the following code gives you just percentage as a number.

ioreg -r -n AppleDeviceManagementHIDEventService -k BatteryPercent | perl -nE '/"BatteryPercent" = (\d++)/ && say $1'

I use this with BetterTouchTool.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .