Desktop-Notify

 view release on metacpan or  search on metacpan

lib/Desktop/Notify.pm  view on Meta::CPAN

    $notification->show();
    
    # Close the notification later
    $notification->close();

=head1 DESCRIPTION

This module provides a Perl interface to the Desktop Notifications framework.

The framework allows applications to display pop-up notifications on an X
desktop.  This is implemented with two components: a daemon that displays the
notifications, and a client library used by applications to send notifications
to the daemon.  These components communicate through the DBus message bus
protocol.

More information is available from
L<http://trac.galago-project.org/wiki/DesktopNotifications>

This module serves the same purpose as C<libnotify>, in an object-oriented Perl
interface.  It is not, however, an interface to C<libnotify> itself, but a
separate implementation of the specification using L<Net::DBus>.

lib/Desktop/Notify.pm  view on Meta::CPAN

Path to an image to use for notification icons.

=item bus

The Net::DBus mesage bus to use. Default is to call Net::DBus->session, which
is usually where notification-daemon can be reached.

=item service

The DBus service name of the daemon. Default is
I<org.freedesktop.Notifications>.

=item objpath

The path to the notifications DBus object. Default is
I</org/freedesktop/Notifications>.

=item objiface

The DBus interface to access the notifications object as. Default is
I<org.freedesktop.Notifications>.

=back

=cut

sub new {
    my ($class, %opts) = @_;

    my $self = {};

    $self->{bus} = $opts{bus} || Net::DBus->session;
    $self->{service} = $self->{bus}
        ->get_service($opts{service} || 'org.freedesktop.Notifications');
    $self->{notify} = $self->{service}
        ->get_object($opts{objpath} || '/org/freedesktop/Notifications',
                     $opts{objiface} || 'org.freedesktop.Notifications');
    $self->{app_name} = $opts{app_name} || basename($0);
    $self->{app_icon} = $opts{app_icon} || '';
    $self->{notify}->connect_to_signal('NotificationClosed',
                                       sub {$self->_close_cb(@_)});
    $self->{notify}->connect_to_signal('ActionInvoked',
                                       sub {$self->_action_cb(@_)});

    bless $self, $class;
}

lib/Desktop/Notify.pm  view on Meta::CPAN


L<Net::DBus>

L<http://www.galago-project.org/specs/notification/index.php>

L<http://www.galago-project.org/downloads.php>

=head1 BUGS

Please report any bugs or feature requests to
C<bug-desktop-notify at rt.cpan.org>, or through the web interface at
L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Desktop-Notify>.
I will be notified, and then you'll automatically be notified of progress on
your bug as I make changes.

=head1 SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc Desktop::Notify

lib/Desktop/Notify/Notification.pm  view on Meta::CPAN


use strict;
use warnings;

use base qw/Class::Accessor/;

Desktop::Notify::Notification->mk_accessors(qw/summary body timeout/);

=head1 NAME

Desktop::Notify::Notification - a notification object for the desktop
notifications framework

=head1 VERSION

Version 0.03

=cut

our $VERSION = '0.03';

t/01-connect.t  view on Meta::CPAN


my $notify;

eval { $notify = new Desktop::Notify };

ok($notify, 'connect with default options');

$notify = undef;
eval { $notify = new Desktop::Notify
           (bus => Net::DBus->session,
            service => 'org.freedesktop.Notifications',
            objpath => '/org/freedesktop/Notifications',
            objiface => 'org.freedesktop.Notifications') };

ok($notify, 'connect with explicit options');



( run in 0.709 second using v1.01-cache-2.11-cpan-299005ec8e3 )