After reading the prior hint on faking transparency for Activity Monitor's Dock icon, I decided that I could settle for no less than true transparency. Knowing that Cocoa's NSColor fully supports it, and acting on a hunch that Activity Monitor was probably archiving the chosen NSColor into the user defaults, I decided to view the com.apple.ActivityMonitor.plist file. Lo and behold, it does. So now the only thing between me and true transparency was an archived instance of NSColor.
The method is relatively simple. First you need a way to generate the archived NSColor.
I chose to write a very simple command-line Objective-C program (transparentcolor.m) as follows:
#import <AppKit/NSColor.h>
#import <Foundation/NSArchiver.h>
#import <Foundation/NSData.h>
#import <Foundation/NSAutoreleasePool.h>
#include <stdio.h>
int main()
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSColor *transparentColor = [NSColor colorWithCalibratedRed:0.0 green:0.0 blue:0.0 alpha:0.0];
NSData *theData = [NSArchiver archivedDataWithRootObject:transparentColor];
size_t length = [theData length];
unsigned char *bytes = malloc(length);
[theData getBytes:bytes];
#if 1
size_t i;
for(i=0; i<length; ++i)
{
printf("%02x", bytes[i]);
}
printf("n");
#else
fwrite(bytes, length, 1, stdout);
#endif
[pool release];
return 0;
}defaults write com.apple.ActivityMonitor CPUIdleColor -data `./a.out`
Take care to notice the back ticks, which cause the shell to use the output of the ./a.out command as the argument to the -data switch.
Mac OS X Hints
http://hints.macworld.com/article.php?story=20070808011626352