Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl -w
- ##
- ## 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);
- use Data::Dumper;
- use File::Slurp;
- our $VERSION = "0.01";
- %IRSSI = (
- authors => ('Luke Macken', 'Markizano Draconus'),
- name => 'notify.pl',
- description => 'Sends notifications to libnotify for when people mention your nick either in channels or private messages.',
- license => 'GNU General Public License',
- url => 'http://lewk.org/log/code/irssi-notify',
- );
- sub notify{
- my ($dest, $text, $message) = @_;
- my $server = $dest->{server};
- my $title = "";
- return if(!$server);
- if(
- $dest->{level} & (MSGLEVEL_HILIGHT | MSGLEVEL_MSGS)
- && ($dest->{level} & MSGLEVEL_NOHILIGHT)
- && ($dest->{level} & MSGLEVEL_CLIENTCRAP) == 0
- ){
- return;
- }
- return if($message !~ m/$server->{wanted_nick}/i);
- return if($message =~ m/^\<.?$server->{wanted_nick}/i);
- $message =~ s/(^-|')/'\\\1'/g;
- $title = "$dest->{target}\@$server->{address}";
- system("notify-send -i terminator -t 5000 '$title' '$message' 2>>/tmp/fnotify.err");
- system("pgrep zenity 2>/dev/null >/dev/null || zenity --notification --text='$title' --window-icon=/usr/share/icons/hicolor/32x32/apps/terminator.png &");
- File::Slurp::write_file('/tmp/fnotify.out', { append => 1 }, "$title\n$message");
- # system("echo '$title\n$message' >> /tmp/fnotify.out");
- }
- Irssi::signal_add('print text', 'notify');
Advertisement
Add Comment
Please, Sign In to add comment