Search code examples
linuxperllibnotify

Is there something better than libnotify?


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).


Solution

  • 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"`;'