]>
git.sthu.org Git - shutils.git/blob - dotfiles/irssi/scripts/notify.pl
2 ## Put me in ~/.irssi/scripts, and then execute the following in irssi:
10 use vars
qw($VERSION %IRSSI);
15 authors => 'Luke Macken, Paul W. Frields',
16 contact => 'lewk@csh.rit.edu, stickster@gmail.com',
18 description => 'Use libnotify to alert user to hilighted messages',
19 license => 'GNU General Public License',
20 url => 'http://lewk.org/log/code/irssi-notify',
23 Irssi::settings_add_str('notify', 'notify_icon', 'gtk-dialog-info');
24 Irssi::settings_add_str('notify', 'notify_time', '5000');
28 encode_entities($text);
33 my ($server, $summary, $message) = @_;
35 # Make the message entity-safe
36 $summary = sanitize($summary);
37 $message = sanitize($message);
39 my $cmd = "EXEC - notify-send" .
40 " -i " . Irssi::settings_get_str('notify_icon') .
41 " -t " . Irssi::settings_get_str('notify_time') .
42 " -- '" . $summary . "'" .
43 " '" . $message . "'";
45 $server->command($cmd);
48 sub print_text_notify {
49 my ($dest, $text, $stripped) = @_;
50 my $server = $dest->{server};
52 return if (!$server || !($dest->{level} & MSGLEVEL_HILIGHT));
53 my $sender = $stripped;
54 $sender =~ s/^\<.([^\>]+)\>.+/\1/ ;
55 $stripped =~ s/^\<.[^\>]+\>.// ;
56 my $summary = $dest->{target} . ": " . $sender;
57 notify($server, $summary, $stripped);
60 sub message_private_notify {
61 my ($server, $msg, $nick, $address) = @_;
64 notify($server, "Private message from ".$nick, $msg);
67 sub dcc_request_notify {
68 my ($dcc, $sendaddr) = @_;
69 my $server = $dcc->{server};
72 notify($server, "DCC ".$dcc->{type}." request", $dcc->{nick});
75 Irssi::signal_add('print text', 'print_text_notify');
76 Irssi::signal_add('message private', 'message_private_notify');
77 Irssi::signal_add('dcc request', 'dcc_request_notify');