Ever needed to remotely check the battery level of a Bluetooth keyboard connected to a Mac? Or maybe you’re just a heavy Terminal user and wanted to see the current battery life of a wireless keyboard without having to leave the command line? You can do that easily through the Terminal of either a remote or local Mac.
It should be mentioned that most Mac users are best served checking their attached Bluetooth devices battery levels directly from the Bluetooth menu, but advanced users may find this command line approach to be appealing, even if for just specific use cases.
How to Find Keyboard Battery Level from Command Line on Mac
Use the following command syntax to retrieve the battery level of any Bluetooth keyboard connected to a Mac, you may want to copy and paste this as shown to have precise syntax. As usual with terminal commands, be sure the entire command string is printed on a single line:
ioreg -c AppleBluetoothHIDKeyboard |grep '"BatteryPercent" ='
Executing the command returns output looking something like the following:
$ ioreg -c AppleBluetoothHIDKeyboard |grep '"BatteryPercent" ='
"BatteryPercent" = 12
In this example, the “12” is the percentage remaining of the Bluetooth devices battery.
If you feel like it, you can double-check the accuracy by looking at the standard Bluetooth battery remaining menu item for that device:
This works great for local and remotely connected Macs through SSH, so there are plenty of uses for this command.
Having the series of quotations is necessary to avoid a bunch of unnecessary output returned by ioreg. Yes, you could pass the grep and ioreg output through awk to get cleaner results, but we’re aiming to keep it simple here. Nonetheless, if you want to experiment yourself, you can try with the following ioreg:
ioreg -c AppleBluetoothHIDKeyboard |grep BatteryPercent
Or to retrieve broader battery information:
ioreg -c AppleBluetoothHIDKeyboard |grep Battery
Let us know in the comments if you have an ideas or find any other useful tricks with this command.
Follow Me:
Top Best Sellers!!