I'm trying to write some code against libnotify, but the documentation for perl with libnotify is seriously lacking. So is there something that, as of 2011-08-26, is "better" than libnotify? All I need is to send a notification to the currently logged in user on a Linux machine (Ubuntu specifically).
-
where is there a perl interface to libinotify? do you have a link? – Joel Berger Aug 26 '11 at 20:32
-
Also is the user at a terminal or x session? – Joel Berger Aug 26 '11 at 20:44
-
@Joel [Gtk2::Notify](http://search.cpan.org/dist/Gtk2-Notify) is what provides the connection to libinotify. And the user will be at an X session. – Glen Solsberry Aug 26 '11 at 20:56
-
ok now I sound ignorant (though by definition I am as I have never used `libinotify`) but are libnotify and libinotify the same? From what I see libinotify is about monitoring file changes, not user notification. – Joel Berger Aug 26 '11 at 20:59
-
@Joel I'm a moron. I've been working with `libinotify` recently as well, and managed to type that in instead of libnotify. Luckily, it seems everyone else worked around my stupidity :) I've modified my question accordingly. – Glen Solsberry Aug 26 '11 at 21:14
-
@gsm8994, no problem. Being unfamiliar with either, I was having a hard time understanding what was going on. – Joel Berger Aug 26 '11 at 21:48
-
Related: http://superuser.com/questions/174885/how-to-write-to-kdes-osd-or-notification-from-console – daxim Aug 29 '11 at 08:35
3 Answers
Gtk2::Notify
does seem to lack good documentation, but you can browse through some examples at http://cpansearch.perl.org/src/FLORA/Gtk2-Notify-0.05/examples/ including the basic one:
#!/usr/bin/perl
use strict;
use warnings;
use Gtk2::Notify -init, 'Basic';
my $n = Gtk2::Notify->new('Summary', 'This is some sample content');
$n->show;
In fact this seems pretty cool, I may use it for something soon! Thanks for bringing it to my attention.
Otherwise:
On Linux you can use zenity
to send a popup message, and to send it to another user's screen you have to play with some environment variables but it can be done. From Perl I would set the appropriate %ENV
values and then just execute system
or backtick (``) calls to zenity
.
Perhaps start here http://www.cyberciti.biz/tips/spice-up-your-unix-linux-shell-scripts.html
Also from within that link, perhaps libnotify-bin
/notify-send
would also work, depending on the message you are sending.
perl -E '$ENV{DISPLAY} = ":0.0";`notify-send "Hello World"`;'

- 20,180
- 5
- 49
- 104
As far as I can tell freedesktop specification contains a notification service which can be accessed via dbus. Here is a link to a perl module for that feature.

- 11
- 2
From what I searched, when porting an application from Windows to Linux, there's no :(
I'll glad to here if there's.
Update: Indeed I was talking about libinotify and not about libnotify.

- 26,717
- 34
- 141
- 196