Friday, January 9, 2009

Using growl with irssi =, mac on irc

Growl is a really neat 3rd party app on the mac that loads a small fading information window on your screen when other applications send it information. So if you get a message on adium a little growl window pops up and tells you who and what they said temporarily, it's not as obtrusive as it sounds. So I have started on a script for irssi, to call growl. My script so far just displays the message that the person says, I haven't gotten it to say who says it yet. And it does something to the display in irrsi, and you have to hi command k, then ctrl-N back to your channel. You may notice the code is a little screwy, that's because originally I was just playing with the 8-ball.pl script on irssi's site. So thank you to Patrik Jansson, who wrote the 8-ball.pl script.

First you will need to make sure growl is installed. Second you will need the growl perl module which you can get by going to cpan in the terminal by typing:sudo cpan
Then you type install Mac::Growl
After it finishes installing make sure you have the scripts directory in ~/.irssi/ and then copy this perl file to it(~/.irssi/scripts/growl.pl):

#Irssi Growl
#
#
use strict;
use vars qw($VERSION %IRSSI);

use Irssi qw(command_bind signal_add);
use IO::File;
use Mac::Growl qw(:all);
$VERSION = '0.1';
%IRSSI = (
authors => 'Dusty Carver',
contact => 'bsdpunk@gmail.com',
name => 'irssiGrowl',
description => 'Growl for irssi',
license => 'GPL',
);

sub own_question {
my ($server, $msg, $target) = @_;
question($server, $msg, "", $target);
}

sub public_question {
my ($server, $msg, $nick, $address, $target) = @_;
question($server, $msg, $nick.": ", $target);
}
sub question($server, $msg, $nick, $target) {
my ($server, $msg, $nick, $target) = @_;
$_ = $msg;
if (!/^*bsdpunk/i) { return 0; }

if (/^*bsdpunk$/i){
Mac::Growl::RegisterNotifications(
# register your application in Growl before posting.
# just one time enough.
'irssiScript', # app name
['alert'], # all notification
['alert'], # default notification
);

Mac::Growl::PostNotification(
# post notification to Growl
"irssiScript", # app name
"alert", # notification type
"irssi", # alert title
"$_", # alert content
);
return 0;
} else {
if(!/^bsdpunk says/i){
return 0;
}
}

}

signal_add("message public", "public_question");
signal_add("message own_public", "own_question");

No comments: