Archive for the 'Macintosh' Category

Screen Saver Function Key
Greg Abbas

I like to start the Mac OS X screen saver by typing a key on the keyboard, using a utility like One Key. I used to do that by just launching ScreenSaverEngine.app, but that seems to have an unpleasant side effect where sometimes two or more screen saver process will try to run at the same time. So instead, I followed seb2's advice and compiled a short program to use the ScreenSaver framework. It doesn't even have a UI, it just activates the screen saver and quits. If you use Leopard (which I recommend! :-) and want to start the screen saver using the keyboard, try this:

  1. Download and install One Key (or Logitech Control Center or some other utility that lets you assign applications to keys on your keyboard)
  2. Download my tiny application, SleepNow, and put it in your /Applications/Utilities folder.
  3. Configure one of your keys to run SleepNow.

Enjoy! SleepNow is free and released to the public domain, and (#include <std_disclaimer.h>) I assume no liability for its use.


Bypassing HID on the Mac
Greg Abbas

Just recently I tried something new (for me)... writing code for the Mac OS that interacts with a USB device (an INSTEON PowerLinc Controller). I'm in over my head so it's been an adventure, to say the least. One of the first hurdles was pretty annoying, and now that I have it licked (I think) I thought I would share my results with the big ole' internet.

Here's the problem: the device I'm trying to write for represents itself as a HID device, but it's not really. The Mac OS seems to make some assumptions about HID devices that aren't really valid for this one, so I needed to talk to it using the lower-level USB API, not the higher-level HID USB functions. But when you plug in a HID device, apparently the Mac's HID driver "grabs" it and won't let you talk to it directly, so I needed a way to tell the HID manager to leave my device alone. After some Googling and experimentation, here's what I found that worked.

I made a new "kext" bundle (that I put in /System/Library/Extensions) that doesn't have any code in it, just an Info.plist and a version.plist. The version.plist didn't require any tweaking; you can just copy and modify one from one of the other kexts in the folder. The Info.plist is where the magic is. Mine looks something like this.

Replace all of the stuff marked CHANGEME with your own names and values, and use USB Prober to find the product ID and vendor ID of your device if you like. Make sure your bundle is owned by root and writable only by its user (i.e., drwxr-xr-x) otherwise the system won't tolerate it (Console.app is good for debugging issues like that). Finally, load the new kernel extension with kextload (or reboot) for it to take effect. If all goes well, now you can use IOKit to call QueryInterface, USBInterfaceOpen, GetNumEndpoints, and so on without receiving any errors about the device already being locked for exclusive access.

p.s.: Caveat programmer. This was tested only on Tiger (Mac OS X version 10.4). When 10.5 comes out maybe it'll change everything, who knows. :-)


The Mac Mini Lives!
Greg Abbas

The various Mac rumor/pundit folks have been predicting the demise of the Mac Mini, which was weary because it's a great little machine. I use mine in the living room as a home-theater PC, and it works really well... I plan to write more about that soon. But in any case, it turns out the "reports of its demise have been greatly exaggerated," because today Steve Jobs announced a new, upgraded line of Mac Minis. Yay! Long live the Mini!


Hotel Gadget
Greg Abbas

Everyone knows that "content is king": that perhaps the most important thing a web site can do is provide fresh information that you didn't know before. But art isn't like that. Good art resonates with your forgotten experiences and awakens patterns inside you. That's what I like about Futurismo Zugakousaku's screen saver, "Hotel Gadget". It's a beautiful composition that has a way of finding long-lost neurons in the dusty corners of your mental attic and brushing the cob-webs off of them.