Skip to content

Instantly share code, notes, and snippets.

@dgeske
Created February 7, 2012 00:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dgeske/1756022 to your computer and use it in GitHub Desktop.
Save dgeske/1756022 to your computer and use it in GitHub Desktop.
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