Jaipo
view release on metacpan or search on metacpan
lib/Jaipo/Notify/LibNotify.pm view on Meta::CPAN
package Jaipo::Notify::LibNotify;
use warnings;
use strict;
#~ use Smart::Comments;
use Data::Dumper;
use base qw(Desktop::Notify);
=encoding utf8
=head1 NAME
Jaipo::Notify::LibNotify - A easy-to-use interface to show desktop notifications with libnotify.
=head1 SYNOPSIS
Jaipo::Notify::LibNotify is a easy-to-use interface to show desktop notifications with libnotify.
It doesn't use libnotify directly, but talking to libnotify via dbus.
use Jaipo::Notify::LibNotify;
my $notify = Jaipo::Notify::LibNotify->new();
# yell for Service Notify.
$notify->yell('Cannot connect to M$-Mi$roBlo$: $!');
# display for message displaying.
$notify->display("From Mr.Right: Hello Darling. How are you today?");
# pop_box for message displaying.
$notify->pop_box("Are you using M$ windows without buying license?");
# get current timeout setting
print Data::Dumper $notify->timeout;
# set yell timeout to 10 seconds. default is 5.
$notify->timeout("yell" => 10);
# set display timeout to 5 seconds. default is 3.
$notify->timeout("yell" => 5);
=head1 FUNCTIONS
=head2 new
Return a object which talks to libnotify via dbus.
=cut
sub new {
my $class = shift;
#~ print Dumper $class;
my $self = Desktop::Notify->new(@_);
bless $self, $class;
$self->{timeout_yell} = 5000;
$self->{timeout_display} = 3000;
return $self;
}
=head2 yell
yell for Service Notify.
Pops a notification with title "Jaipo Service Notify" and the given message content from you.
=cut
sub yell {
my ($self, $msg) = @_;
$self->create(
"summary" => 'Jaipo Service Notify',
"body" => $msg,
"timeout" => $self->{timeout_yell},
)->show();
}
=head2 display
( run in 1.393 second using v1.01-cache-2.11-cpan-d06a3f9ecfd )