jolttz's blog #!/usr/bin/perl

18Jul/100

[Perl] Highlight notification in Irssi

I wrote a simple script that shows you a little notification on the top-right corner of your screen when someone highlights you. It uses notify-send to display the notification. If you don't have it just install "notify-osd" with your package manager. There are two things you might want to change: the icon for notification and the duration it displays the notification. The duration is in milliseconds so 1000ms = 1s.

Here's the script in action:

irssi-notification perl script by jolttz

irssi-notification

You need to save the script to "~/.irssi/scripts/autorun" or where ever your Irssi folder is located and load it by writing "/script load scripts/autorun/irssi-notification" inside Irssi.

#!/usr/bin/perl
#           irssi-notification.pl
#  Sun Jul 18 16:54:32 2010
#  Copyright  2010  jolttz
#  jolttz{ät}gmail{dot}com
#

use strict;
use Irssi;
use vars qw($VERSION %IRSSI);
Irssi::signal_add('print text', 'notify');

my $icon = "/usr/share/icons/gnome/scalable/actions/mail-message-new.svg"; # Path to icon file
my $duration = "4000"; # Duration in milliseconds

$VERSION = "0.02";
%IRSSI = (
    authors     => 'jolttz',
    contact     => 'jolttz{at}gmail[dot]com',
    name        => 'irssi-notification.pl',
);

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

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

    system("notify-send -i ". $icon ." -t ". $duration ." '$dest->{target}' '$stripped'");
}
Filed under: Tech blog Leave a comment
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


No trackbacks yet.