My blog has moved!

You should be automatically redirected in 6 seconds. If not, visit
http://www.mattdturner.com/wordpress
and update your bookmarks.

AdSense

Pages

Showing posts with label Mac. Show all posts
Showing posts with label Mac. Show all posts

Thursday, April 21, 2011

Mac Bluetooth Keyboard/Mouse Battery Level in Terminal

There are a few reasons why somebody might want to check the current battery percentage of a bluetooth mouse and/or keyboard within Terminal on a mac.  Some that come to mind are for use in GeekTool, if you are connected to the computer remotely through ssh, etc.

Well as it turns out, its actually very easy to do.  The tool that we will use to check the battery percentage is called "ioreg".  The Mac OS X manual describes ioreg as a tool that "displays the I/O Kit registry. It shows the hierarchical registry structure as an inverted tree."

There are many options available with the ioreg tool, however this article will just be discussing how to check the battery percentage of different devices.  See the below text for the code to view the battery percentage:

matthewturner/~:  ioreg -n "IOAppleBluetoothHIDDriver" | grep -i "batterypercent" | sed 's/[^[:digit:]]//g'
49
matthewturner/~:  ioreg -n "BNBMouseDevice" | grep -i "batterypercent" | sed 's/[^[:digit:]]//g'
45
matthewturner/~:  ioreg -n "BNBMouseDevice" | grep -i "batterypercent"
    | |   |     | | |   |   "BatteryPercent" = 45

There are a few things that should be noted about the above commands.

Sunday, April 17, 2011

A Fix for Broken Bluetooth in Mac OS X

After updating my Mac to OS 10.6.7, I ran into a problem where the bluetooth on the computer would completely fail. I tried many times to disconnect and re-connect my mouse and keyboard, but the problem still persisted.

I tried deleting the pairing and re-pairing the devices, but I would get the following message:

”The pairing attempt was unsuccessful. This configuration of Mac OS X and Bluetooth software could be invalid or unsupported.”



Resetting the SMC seemed to fix the problem.

To summarize the steps listed in the link, do the following to reset the SMC on your MacBook:

  • Shut down the computer.
  • Ensure that the MagSafe power adapter is connected to the computer.
  • On the built-in keyboard, press the left Shift-Control-Option keys and the power button at the same time.
  • Release all keys and the power button at the same time.
  • Press the power button to turn on the computer.
Note: The LED on the MagSafe power adapter may change states or temporarily turn off when you reset the SMC.