依赖的Perl第三方lib为Gtk2::Notify
Ubuntu下安装:
sudo apt-get install libgtk2-notify-perl
代码如下:
#!/usr/bin/perl -w use Gtk2::Notify -init, "Test Perl Notify"; use Encode; my $summary = "summary here"; my $message = "message here"; my $icon = "/usr/share/icons/hicolor/128x128/apps/fwbuilder.png"; my $attach_widget = undef; my $notification = Gtk2::Notify->new($summary, $message, $icon, $attach_widget); $notification->show;
效果如图:

后记:
有这么一款Firefox扩展,可以实现Firefox下载完成的任务栏消息提示。查看了一下它的代码,发现是用python实现的libnotify接口。只需要改一下xpi文件中的install.rdf就可以在3.6版本的Firefox上安装了。扩展安装地址:https://addons.mozilla.org/en-US/firefox/addon/9622/
按照这个方法,其实很多Web应用程序都可以借此实现Linux下的任务栏消息提示集成。有时间的话我来写一个WebQQ的消息提示扩展玩玩。
原创文章,转载请注明: 转载自猪在笑 [ http://www.huangwei.me/blog/ ]
本文链接地址: http://www.huangwei.me/blog/2010/08/02/perl-gtk2-libnotify/
最近评论