-
Notifications
You must be signed in to change notification settings - Fork 0
/
gnotify.pl
111 lines (72 loc) · 2.32 KB
/
gnotify.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/usr/bin/env perl
use 5.10.0;
use vars qw($VERSION %IRSSI);
use Gtk3::Notify -init, "irssi";
use Irssi;
$VERSION = '0.0.1';
%IRSSI = (
authors => 'David Farrell',
contact => 'perltricks.com@gmail.com',
name => 'gnotify',
description => 'Creates Gnome3 popup alert when your nick is mentioned or you are private messaged',
url => 'https://github.com/sillymoose/irssi/blob/master/gnotify.pl',
license => 'GNU General Public License',
changed => '$Date: 2014-05-31 20:44:00 -0400 (Sat, 31 May 2014) $'
);
=head1 DESCRIPTION
This is an irssi script that creates a Gnome3 alert popup in your window when your nick is mentioned or you are private messaged.
=head1 INSTALLATION
Place this file in your user irrsi directory, e.g:
~/.irssi/script/gnotify.pl
Within irrsi you can load the script:
/script load gnotify.pl
You can also create a simlink to autoload the script when irssi starts:
$ mkdir ~/.irssi/script/autorun
$ cd ~/.irssi/script/autorun
$ ln -s ../gnotify.pl
=cut
=head1 SUBROUTINES
=head2 priv_msg
Called when you get a private message. Calls alert()
=cut
sub priv_msg {
my ($server,$msg,$nick,$address,$target) = @_;
alert($nick." " .$msg );
}
=head2 priv_msg
Called when your nick is mentioned. Calls filewrite() and alert()
=cut
sub hilight {
my ($dest, $text, $stripped) = @_;
if ($dest->{level} & MSGLEVEL_HILIGHT) {
alert($dest->{target}. " " .$stripped );
}
}
=head2 alert
Creates the popup alert!
=cut
sub alert {
my $notification = Gtk3::Notify::Notification->new('New irssi message', shift);
$notification->show;
}
# binds subs to Irssi signal / events
Irssi::signal_add_last("message private", "priv_msg");
Irssi::signal_add_last("print text", "hilight");
=head1 THANKS
Based on fnotify.pl by Thorsten Leemhuis
=cut
=head1 WARNING
Gtk3::Notify v0.01 test file *may* not work on install. I've filed a patch with the author, but in meantime if you need to install Gtk3::Notify:
$ cpan -fi Gtk3::Notify
Voila!
Bear in mind that Gtk3 has some C dependencies which you'll need to install. My yum log shows I installed:
glib-devel
perl-Glib-devel
libtool
gobject-introspection
gobject-introspection-devel
perl-Cairo
perl-Cairo-GObject
cairo-gobject-devel
There may be more!
=cut