How can I check the battery level of a connected Bluetooth device? The device shows the battery level on Android, so I'm assuming the device supports the GATT-based Battery Service.
However, by entering "menu gatt" in bluetoothctl and then listing the GATT attributes of the device with "list-attributes [dev]", nothing shows up.
There is a similar Stack Overflow question, How to check the battery level of a Bluetooth paired remote (now deleted, only visible to users with more than 10,000 reputation points), but the OP seems to have found a solution that doesn't work for me. When I run "info [dev]" in bluetoothctl, I don't see the UUID for 'Battery Service'.
I would prefer a solution that runs on the command line and is Linux distribution-agnostic.
For me, this Python project has worked fine:
Bluetooth Headset Battery Level
I only had to change the port in line 57 to 3 for my no-name X5 headset. If it hangs or errors with "connection refused", try a different port.
The Python program uses AT commands via RFCOMM and should work while PulseAudio is using the A2DP sink (mine reconnects). Python 3 is needed as 2 doesn't have BT-Serial sockets. Windows will probably not work as it lacks BlueZ. It basically does the same thing as the PulseAudio hack at Check battery level of connected Bluetooth device on Linux.
If you want to look at the commands as they are exchanged, try my debug fork of Bluetooth Headset Battery Level.