Archives / Search ›

Setting display brightness: updated tool

Here is my cleaned-up brightness tool, which now uses the IOKit APIs instead of the weird O3Engine SPIs that the old version did.

Quick example:

% ./brightness 
usage: ./brightness [-m|-d display] [-v] <brightness>
   or: ./brightness -l [-v]
% ./brightness -l
display 0: main display, ID 0x4270a80
display 0: brightness 0.734375
% ./brightness -v 0.3
display 0: brightness 0.296875

-m changes the brightness of the main display; -d changes brightness of whatever display number/ID you provide. -l -v dumps display attributes—sorry for the ugly XML output, but CoreFoundation claims to be unable to output an OpenStep-format property list even though Cocoa has no problem doing the same.

(February 2014: Please see an updated version of this code on GitHub; it makes the -v output more readable among other changes.)

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.)

Universal F-Script Anywhere released

F-Script Anywhere is now part of the main F-Script distribution, available at fscript.org. Version 1.3 is compatible with Mac OS X 10.4.x, and is a Universal Binary. Many thanks to Robert Chin for picking up FSA’s development.

I still don’t have access to an Intel Mac, but with some help, a Universal build of ICeCoffEE should be ready in the next few weeks.

This American Life track munger

Since This American Life has switched from streaming in RealAudio to MP3, Jon Udell and Jared Benedict have posted some unofficial podcast feeds. Unlike with my previous RealPlayer-to-Audio Hijack Pro-to-iTunes-as-AAC solution, the MP3 files aren’t bookmarkable on my 3G iPod, but they are certainly a lot more convenient to grab for later listening.

Which reminds me, since other people may find it useful—a few weeks ago, I wrote a script which operates on the selected This American Life MP3 tracks in iTunes, renames them to match my existing scheme, and moves the episode number to the track field (especially useful on older iPods where the episode number takes up half the width of the screen).

TALize.png

Download the script here. Sorry for the image; Script Debugger 3’s HTML export appears to have broken—and since I have primarily switched to appscript, I can’t justify the upgrade to version 4. The string parsing pain above should be enough to send anyone running to Python.

“Fun” OS X disk image bug

So I was trying to install OpenSolaris on a CD-less SPARC system using an OS X machine as an install server (because said machine is barfing under FreeBSD, and I’m trying to figure out if it was a hardware problem).

After downloading the DVD image in four pieces, concatenating them together, and mounting it, I think I may have run into some weird disk imaging or filesystem bug on OS X. It’s really rather scary.

% uname -a
Darwin bookworm.local 8.6.0 Darwin Kernel Version 8.6.0: Tue Mar  7 16:58:48 PST
 2006; root:xnu-792.6.70.obj~1/RELEASE_PPC Power Macintosh powerpc
% hdid sol-nv-b40-sparc-dvd.iso
/dev/disk2                                              /Volumes/SOL_11_SPARC
% cp /Volumes/SOL_11_SPARC/Solaris_11/Tools/add_install_client ./one
% disktool -e disk2 0
[...]
***Disk Ejected('disk2')
% hdid sol-nv-b40-sparc-dvd.iso
/dev/disk2                                              /Volumes/SOL_11_SPARC
% cp /Volumes/SOL_11_SPARC/Solaris_11/Tools/add_install_client ./two
% diff one two
Binary files one and two differ
% file one two
one: data
two: data

add_install_client is supposed to be a shell script. A few times running strings on it, I found some OS X filesystem bits, for example:

% strings add_install_client
[...]
ntpd
snmpd
Starter
RetroRun
rter
crashreporterd
[...]
tarter
apcupsd
arter
serialnumberd
ARDHelper
zsh: 697 bus error  strings add_install_client

No time to debug further at the moment, but… yuck.

Older Posts ›