Stupid Mac::Glue/X-Chat Tricks

| | Comments (0)
X-Chat has a perl interpreter plugin that allows you to compile (and cache, like mod_perl) perl scripts.

One of its functions is to open a URL in a wbe browser when you click on it in a window. gets the URL and opens it via system('open', $url).

I leave X-Chat Aqua open on my server 24/7. Then I use my laptop, right next to it, to do most other work, including web browsing. I've been using ClipboardSharing to automatically sync my clipboards between the two machines, so I can copy the URL in X-Chat on the server, and then paste it in a browser window on my laptop.

But I decided, why not have clicking on the URL open a browser window on my laptop instead of the local server?

Enter Mac::Glue!

I added this to the top of

use Mac::Glue ':all';
my $browser = new Mac::Glue 'Safari';
my $version = $browser->prop('version');
my @hosts = qw(bourque orr);
sub _gethost {
    my $found = 0;
    for my $host (@hosts) {
        $browser->ADDRESS(eppc => Safari => $host);
        $found = 1, last if &_alive;
    $browser->ADDRESS if !$found;
sub _alive {
    return $version->get;

And then changed the open line:

#    system ("open", $url);

Now, if my laptop is on the network (both hostnames are the same machine, one wireless hostname and one wired), it will open the URL on the laptop when I click on it. Otherwise, it opens it locally. Nifty.

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 January 21, 2004 1:23 PM.

Sunday Thoughts was the previous entry in this site.

Dean QuickHit is the next entry in this site.

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