A better fnotify.pl for local irssi

For various reasons i run irssi locally on the box that use, i also use fnotify.pl in order to get pretty notifications when someone wants my attention, alas fnotify.pl is designed to be used remotly over ssh, great if you have a load of boxes and don’t run irssi on the box your using. but for people like me it was a bit clunky and annoying (had to run a seperate script to read the files it wrote, the script would often get caught up in gnome sessions without exiting causing lots of scripts to be loaded after several logons)

So i altered the fnotify.pl script to work entirely out of one script (thats loaded into irssi via the normal methods). this has the side effect of only working localy but for anyone else like me, its a rather usefull addition. you’ll need notify-send installed.

# todo: grap topic changes

use strict;
use vars qw($VERSION %IRSSI);

use Irssi;
$VERSION = '0.0.3';
%IRSSI = (
	authors     => 'Thorsten Leemhuis',
	contact     => 'fedora@leemhuis.info',
	name        => 'fnotify',
	description => 'Write a notification to a file that shows who is talking to you in which channel.',
	url         => 'http://www.leemhuis.info/files/fnotify/',
	license     => 'GNU General Public License',
	changed     => '$Date: 2007-01-13 12:00:00 +0100 (Sat, 13 Jan 2007) $'

# In parts based on knotify.pl 0.1.1 by Hugo Haas
# http://larve.net/people/hugo/2005/01/knotify.pl
# which is based on osd.pl 0.3.3 by Jeroen Coekaerts, Koenraad Heijlen
# http://www.irssi.org/scripts/scripts/osd.pl
# Other parts based on notify.pl from Luke Macken
# http://fedora.feedjack.org/user/918/

# Private message parsing

sub priv_msg {
	my ($server,$msg,$nick,$address,$target) = @_;
	filewrite($nick." " .$msg );

# Printing hilight's

sub hilight {
    my ($dest, $text, $stripped) = @_;
    if ($dest->{level} & MSGLEVEL_HILIGHT) {
	filewrite($dest->{target}. " " .$stripped );

# The actual printing
sub filewrite {
	my ($text) = @_;
	# FIXME: there is probably a better way to get the irssi-dir...
    #    open(FILE,">>$ENV{HOME}/.irssi/fnotify");
	#print FILE $text . "\n";
    #    close (FILE);
    $text =~ s/\n/ /;
    $text =~ s/[<@&]//g;

    my @values = split(' ', $text, 2);

    `notify-send -t 5000 -u critical -c im.received -i /usr/share/icons/gnome/scalable/emotes/face-surprise.svg "$values[0]" "$values[1]"`;


# Irssi::signal_add_last / Irssi::command_bind

Irssi::signal_add_last("message private", "priv_msg");
Irssi::signal_add_last("print text", "hilight");

#- end

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s