Sep 21, '04 10:34:00AM • Contributed by: Anonymous
First, set up a folder containing your regular desktop picture ("normal.pct") and a warning desktop picture ("warn.pct"). Mine is ~/Picture -> Desktop Pictures. Inside that folder, set up a subfolder called "Active," and set your desktop preferences to rotate images from that folder every minute or so.
Place the following perl script in your Desktop Pictures folder, give it the proper executable privileges with chmod, and call it activate.pl:
#!/usr/bin/perl
chomp(my $basedir = `dirname "$0"`);
chdir $basedir;
my $active_image = 'normal.pct';
my $load_threshold = 1.7;
if(($_ = `w`) && /load averages: +([\d\.]+) +([\d\.]+) +([\d\.]+)/) {
if($2 > $load_threshold) {
$active_image = 'warn.pct';
}
}
unlink("Active/active_a.pct");
unlink("Active/active_b.pct");
link($active_image, "Active/active_a.pct");
link($active_image, "Active/active_b.pct");
Finally, add the following line to your crontab, using crontab -e:
*/2 * * * * /Users/your_username/Pictures/Desktop\ Pictures/activate.pl
If this works correctly, you will have a desktop image that smoothly changes from normal.pct to warn.pct when your load average stays over 1.7 for five minutes or so. In my case, warn.pct is solid red, and heightened CPU usage for an extended period of time shows up as a slow background fade to fire engine red. If you are comfortable with perl, you can modify the if() statement to change images based on other chosen conditions, or show different images depending on situations that demand your attention.
