Monday, August 25, 2008

use your memory usage as your iChat status message


This script will let you use your iChat status message to brag to your friends about how much RAM you've got in your Mac -- or more usefully, petition the IT overlords for mercy if you're scratching to disk a little too much.

I have this triggered periodically by Keyboard Maestro, but there are other ways to get it to run every so often. Not too often, or the overlords will have an easy (if specious) excuse for why it's your own fault you're running out of RAM.



Briefly, it runs a "top" shell command and extracts the two most rhetorically significant memory usage figures, and pipes that to iChat.



set myoutput to (do shell script "top -l 1 | perl -pe " & quoted form of "

my ($unwanted, $wanted) = /(.*inactive,)(.*free)/sm;
$_ = $wanted;

")

tell application "iChat"
    set status message to myoutput
end tell

No comments: