What's Happening
So I've put together a script to update my iChat status, and it has evolved over time. It used to work with iChatStatus, but now iChat AV is scriptable, so I can update the status message from Mac::Glue.
The script I use now is called happening, and it forks itself into the background (startup of Mac::Carbon stuff is still pretty slow and processor-intensive in dyld, so it stays running all the time ... besides, I set it to run every 15 seconds anyway), and then runs through a series of checks on each loop.
It first looks to see if I am watching EyeTV locally, then looks to see if I am listening to an MP3 in iTunes. Then it calls another machine, executing a similar script, to see if that machine is running EyeTV or iTunes (right now this is done via ssh, but I am going to rewrite that remote script to also be a daemon, and have it write out a file I can check via HTTP; much more efficient).
If all those fail, it shows the current app, and if somehow that fails, it puts up something from fortune(6).
It makes heavy use of Mac::Glue to talk to iChat, iTunes, EyeTV, and System Events. It's super sweet! Note how it caches objects it is going to reuse ... makes it super fast and efficient, too. There are a bunch of me-specific things hardcoded in it ... sorry if that gets in your way. :-)
Here are the key lines for talking to iChat:
The script I use now is called happening, and it forks itself into the background (startup of Mac::Carbon stuff is still pretty slow and processor-intensive in dyld, so it stays running all the time
It first looks to see if I am watching EyeTV locally, then looks to see if I am listening to an MP3 in iTunes. Then it calls another machine, executing a similar script, to see if that machine is running EyeTV or iTunes (right now this is done via ssh, but I am going to rewrite that remote script to also be a daemon, and have it write out a file I can check via HTTP; much more efficient).
If all those fail, it shows the current app, and if somehow that fails, it puts up something from fortune(6).
It makes heavy use of Mac::Glue to talk to iChat, iTunes, EyeTV, and System Events. It's super sweet! Note how it caches objects it is going to reuse
Here are the key lines for talking to iChat:
$status = $ichat->prop('status');
return unless $status->get eq 'available';
$message = $ichat->prop('status message');
$message->set(to => $output);
Leave a comment