[Script] irssi + ubuntu notify-osd (notification system)

I was on #ubuntu-fr trying to help people, and a person talked about irssi-notify script. It’s a irssi script written in perl, that when there is message with your name in it (even highlights should work too), a notification pops-up (using the ubuntu notification system).

That’s very helpful. Plus it says the channel! Here’s a screenshot:

irssi with ubuntu notification system

Instructions:

  • You need the notify-send program, you can install it typing this command: sudo apt-get install libnotify-bin or you can find libnotify-bin in synaptic.
  • Then, open the ~/.irssi/scripts directory, create them if they do not exist.
  • Put the file (see below) in this directory,
  • Right-click on the file and choose properties,
  • In the permissions tab, check the box “Allow executing file as a program”.
  • Then right-click on it again
  • Choose create a link.
  • Move the link into the autorun folder (~/.irssi/scripts/autorun), create it if it doesn’t exist.

notify.pl

##
## Put me in ~/.irssi/scripts, and then execute the following in irssi:
##
##       /load perl
##       /script load notify
##

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

$VERSION = "0.01";
%IRSSI = (
    authors     => 'Luke Macken',
    contact     => 'lewk@csh.rit.edu',
    name        => 'notify.pl',
    description => 'TODO',
    license     => 'GNU General Public License',
    url         => 'http://www.csh.rit.edu/~lewk/code/irssi-notify',
);

sub notify {
    my ($dest, $text, $stripped) = @_;
    my $server = $dest->{server};

    return if (!$server || !($dest->{level} & MSGLEVEL_HILIGHT));

    $stripped =~ s/[^a-zA-Z0-9 .,!?\@:\>]//g;
    system("notify-send -i gtk-dialog-info -t 5000 '$dest->{target}' '$stripped'");
}

Irssi::signal_add('print text', 'notify');

Script Source: http://lewk.org/blog/irssi-notify

[ad]

Leave a Reply