Cocoa-Growl
view release on metacpan or search on metacpan
notification.
* defaults => 'ArrayRef'
List of notification names to enable by default. If this parameter
is not set, all notifications is to become default.
growl_notify(%parameters)
Show growl notify.
growl_notify(
name => 'Notification1',
title => 'Hello!',
description => 'Growl world!',
);
Available options are:
* name => 'Str' (Required)
The internal name of the notification. Should be human-readable, as
it will be displayed in the Growl preference pane. And this value is
required to be registered by "growl_register" before calling this
function.
* title => 'Str'
The title of the notification displayed to the user.
* description => 'Str'
The full description of the notification displayed to the user.
* icon => 'Str'
Image file path or URL to show with the notification as its icon. If
this value is not set, the application's icon will be used instead.
* sticky => 'Bool'
If true value is set, the notification will remain on screen until
clicked. Not all Growl displays support sticky notifications.
* priority => 'Int'
The priority of the notification. The default value is 0; positive
values are higher priority and negative values are lower priority.
Not all Growl displays support priority.
* on_click => 'CodeRef',
This callback is called when notification is clicked. See also
CALLBACK NOTICE below.
* on_timeout => 'CodeRef',
This callback is called when notification is timeout. (also called
notification closed by close button)
CALLBACK NOTICE
You should run Cocoa's event loop NSRunLoop to be enable callbacks.
Simplest way to do that is use this module with Cocoa::EventLoop.
use Cocoa::EventLoop;
use Cocoa::Growl ':all';
growl_register(
name => 'test script',
notifications => ['test notification'],
);
my $wait = 1;
growl_notify(
name => 'test notification',
title => 'Hello',
description => 'Growl World!',
on_click => sub {
warn 'click';
$wait = 0;
},
on_timeout => sub {
warn 'timeout';
$want = 0;
},
);
Cocoa::EventLoop->run_while(0.1) while unless $wait;
If you want to write more complicated script, use AnyEvent. AnyEvent 5.3
or higher is support Cocoa::EventLoop internally, so you can use cocoa's
event loop transparently in your AnyEvent application. See
AnyEvent::Impl::Cocoa for more detail.
USE YOUR OWN Growl.framework
Although this module bundle Growl.framework and load it by default, you
can load your own Growl.framework. To do that, save your Growl.framework
to "/Library/Frameworks/Growl.framework/", and add
"USE_LOCAL_GROWL_FRAMEWORK=1" option when run Makefile.PL
perl Makefile.PL USE_LOCAL_GROWL_FRAMEWORK=1
AUTHOR
Daisuke Murase <typester@cpan.org>
COPYRIGHT AND LICENSE
Copyright (c) 2010 by KAYAC Inc.
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
The full text of the license can be found in the LICENSE file included
with this module.
( run in 0.583 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )