Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

pudge (1)

pudge
  (email not shown publicly)
http://pudge.net/
AOL IM: Crimethnk (Add Buddy, Send Message)

I run this joint, see?

Journal of pudge (1)

Wednesday January 21, 2004
04:23 PM

Stupid Mac::Glue/X-Chat Tricks

[ #16943 ]

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. browser.pl 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 browser.pl:

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);
    _gethost(1);
    $browser->activate;
    $browser->open_location($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.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.