summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul W. Frields <stickster@gmail.com>2007-01-15 05:59:12 +0000
committerPaul W. Frields <stickster@gmail.com>2007-01-15 05:59:12 +0000
commitaa95c020e20c75421591ae6d65f26551ad768dc4 (patch)
tree447c30f037bd374e1716e937f2a15206de5ee88d
parentd1929565065ac668944d63b94f8512a74d41b9b0 (diff)
downloadirssi-notify-aa95c020e20c75421591ae6d65f26551ad768dc4.tar.gz
irssi-notify-aa95c020e20c75421591ae6d65f26551ad768dc4.tar.xz
irssi-notify-aa95c020e20c75421591ae6d65f26551ad768dc4.zip
Imported notify script
git-svn-id: https://irssi-libnotify.googlecode.com/svn/trunk@6 291cbfae-0d27-0410-99d7-557b17e6fe3d
-rw-r--r--notify.pl59
1 files changed, 59 insertions, 0 deletions
diff --git a/notify.pl b/notify.pl
new file mode 100644
index 0000000..8dbfc16
--- /dev/null
+++ b/notify.pl
@@ -0,0 +1,59 @@
+##
+## 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, Paul W. Frields',
+ contact => 'lewk@csh.rit.edu, stickster@gmail.com',
+ name => 'notify.pl',
+ description => 'Use libnotify to alert user to hilighted messages',
+ license => 'GNU General Public License',
+ url => 'http://lewk.org/log/code/irssi-notify',
+);
+
+Irssi::settings_add_str('notify', 'notify_icon', 'gtk-dialog-info');
+Irssi::settings_add_str('notify', 'notify_time', '5000');
+
+sub notify {
+ my ($server, $summary, $message) = @_;
+
+ # Make the message entity-safe
+ $message =~ s/&/&amp;/g; # That could have been done better.
+ $message =~ s/</&lt;/g;
+ $message =~ s/>/&gt;/g;
+ $message =~ s/'/&apos;/g;
+
+ my $cmd = "EXEC - notify-send" .
+ " -i " . Irssi::settings_get_str('notify_icon') .
+ " -t " . Irssi::settings_get_str('notify_time') .
+ " '" . $summary . "'" .
+ " '" . $message . "'";
+
+ $server->command($cmd);
+}
+
+sub print_text_notify {
+ my ($dest, $text, $stripped) = @_;
+ my $server = $dest->{server};
+
+ return if (!$server || !($dest->{level} & MSGLEVEL_HILIGHT));
+ notify($server, $dest->{target}, $stripped);
+}
+
+sub private_msg_notify {
+ my ($server, $msg, $nick, $address) = @_;
+
+ return if (!$server);
+ notify($server, "Private message from ".$nick, $msg);
+}
+
+Irssi::signal_add('print text', 'print_text_notify');
+Irssi::signal_add('message private', 'private_msg_notify');