Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
GeekTool Bluetooth Keyboard and Magic Mouse Battery Status
kbatt=`ioreg -c AppleBluetoothHIDKeyboard | grep BatteryPercent | awk -F"=" {'print $2'}` &&
if [ ${#kbatt} -gt 0 ]; then echo "Bluetooth Keyboard: $kbatt%"; fi &&
tbatt=`ioreg -c BNBTrackpadDevice | grep BatteryPercent | tail -1 | awk -F"=" {'print $2'}` &&
if [ ${#tbatt} -gt 0 ]; then echo "Magic Trackpad Battery: $tbatt%"; fi &&
mbatt=`ioreg -c BNBMouseDevice | grep BatteryPercent | tail -1 | awk -F"=" {'print $2'}` &&
if [ ${#mbatt} -gt 0 ]; then echo "Mouse Battery: $mbatt %"; fi;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment