iChatStatus

| | Comments (0)
iChatStatus is a cool little utility that can automate your iChat status message. It is primarily used, probably, to show what is playing in iTunes.

I took two of the scripts, one for iTunes and one for EyeTV, and combined them into one, looking first at EyeTV and then iTunes. This script is installed on my server box, which houses the EyeTV and iTunes players I normally use.

Then, I wrote a Perl script that first sees if iTunes is playing, and if not checks that script on the remote box, and if not, gets the current front application. It uses Mac::Glue for Mac OS X, which is not yet released, but will be someday ... :-)

Note that iChatStatus does not use Apple events to update iChat, as iChat is not scriptable. It uses the private iChat frameworks, which are subject to change.

#!/usr/bin/perl
use strict;
use warnings;
no warnings 'utf8';
 
use Mac::Apps::Launch;
use Mac::Glue ':all';
use Socket;
 
my $itunes = new Mac::Glue 'iTunes';
 
if (IsRunning($itunes->{ID})) {
    my $status = $itunes->get( $itunes->prop('player state') );
    if ($status eq 'playing') {
        my $track = $itunes->prop('current track');
 
        my %info;
        for my $prop (qw(name artist album)) {
            $info{$prop} = $itunes->get( $itunes->prop($prop => $track) );
        }
        print "\x{266C} $info{name} - $info{artist}";
        exit;
    }
}
 
# only try this if i am at home
my $ip = inet_ntoa(inet_aton("bourque.pudge.net"));
if ($ip eq '10.0.1.177') {
    my $result = `ssh sweeney osascript ~/Library/Scripts/myscript.scpt`;
    if ($result =~ /\w/) {
        print $result;
        exit;
    }
}
 
my $system = new Mac::Glue 'System Events';
my $app = $system->prop(name => item => 1,
    application_process => whose(frontmost => equals => 1)
);
print "Using: ", $system->get($app);
 
__END__

use.perl.org

Leave a comment

<pudge/*> (pronounced "PudgeGlob") is thousands of posts over many years by Pudge.

"It is the common fate of the indolent to see their rights become a prey to the active. The condition upon which God hath given liberty to man is eternal vigilance; which condition if he break, servitude is at once the consequence of his crime and the punishment of his guilt."

About this Entry

This page contains a single entry by pudge published on April 23, 2003 4:58 AM.

New Journal RSS Stuff was the previous entry in this site.

Journalspotting is the next entry in this site.

Find recent content on the main index or look in the archives to find all content.