Stupid Mac::Glue Tricks

| | Comments (0)
I use this with XChat Aqua. Note that I create the objects outside the handler: XChat smartly caches the script, so the objects are created once. That, combined with only loading the modules once, significantly decreases the execution time, to nearly nil.

Also, I use IsRunning() to see if I am running iTunes locally; if so, it uses that, and if not, it uses the other box running in the house.

I had to install Mac::Glue etc. for the system perl, which I rarely use, but the plugin library is only compatible with that one. But I made the directory containing the glues a symlink to my local perl's (`sudo ln -s /usr/local/lib/perl5/site_perl/5.8.0/Mac/Glue/glue s /Library/Perl/5.8.1/Mac/Glues/` or whatever). Those are just Storable + MLDBM, I don't need separate copies of them.

use strict;
use Mac::Apps::Launch;
use Mac::Glue;
my $itunes = new Mac::Glue 'iTunes';
my $track = $itunes->prop('current track');
my $name = $track->prop('name');
my $artist = $track->prop('artist');
my $album = $track->prop('album');
sub np {
    if (IsRunning($itunes->{ID})) {
    } else {
        $itunes->ADDRESS(eppc => iTunes => 'sweeney.local');
    my @data = map { $_->get } ($name, $artist, $album);
    my $str = $data[0];
    return 0 unless $str;
    $str = "$str - $data[1]" if $data[1];
    $str = "$str ($data[2])" if $data[2];
    IRC::command("NP: $str");
    return 1;
IRC::register("np", "1.0", "", "");
IRC::add_command_handler("np", "np");

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 November 17, 2003 1:07 PM.

More Toys was the previous entry in this site.

Hey, That Web Browser is Not a MySQL Server is the next entry in this site.

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