Monday, 19 June 2006
Setting display brightness
Amit Singh has posted some source code for reading the ambient light sensor on appropriately equipped Apple laptops, and changing the keyboard and display backlight brightness. He sets the display brightness with only documented APIs, which is quite a bit cleaner than the code to do so I wrote about 7 months ago. Needless to say, at the time I couldn't find the appropriate IOKit methods to do so, so I ended up reverse engineering what the display preference pane did. It's rather strange that the convoluted Objective-C interface exists, since the IOKit code actually seems shorter!
One thing my code does that Amit's doesn't is change the brightness on all connected LCDs, not just the main display (which may not be the internal LCD if you've got a laptop connected to an external monitor). This should be easy enough to merge.
(February 2014: Please use the updated version of this code on GitHub.)