Hi All.
I made a couple of extension attributes for querying the battery levels of Bluetooth Trackpads and Keyboards that may be useful to others.
Bluetooth Keyboard:
#!/bin/sh
kresult=`ioreg -r -c "AppleBluetoothHIDKeyboard" | grep -w BatteryPercent | sed 1d | awk '{print $4}' | sed s/"//g`
echo "<result>$kresult</result>"
Magic trackpad:
#!/bin/sh
tpBatLevel=`ioreg -r -c "BNBTrackpadDevice" | grep -w BatteryPercent | sed 1d | awk '{print $4}' | sed s/"//g`
echo "<result>$tpBatLevel</result>"
You can then create smart groups using these to generate notifications for low batteries. One thing to be aware of: If the keyboard or trackpad is asleep as the time the value is connected you will not get a value returned , so when creating a smart group you will need to add a is not and leave the field blank, otherwise you will get a lot of incorrect notifications.
This is also possible for bluetooth mice but I don't have one handy to find out the device name.
