Daisuke Murase > Cocoa-Growl-0.05 > Cocoa::Growl

Download:
Cocoa-Growl-0.05.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.05   Source  

NAME ^

Cocoa::Growl - Yet another growl module using Growl.framework

SYNOPSIS ^

    use Cocoa::Growl ':all';
    
    my $installed = growl_installed(); # true if Growl is installed.
    my $running   = growl_running();   # true if Growl is running.
    
    # register application
    growl_register(
        app           => 'My growl script',
        icon          => '/path/to/icon.png', # or 'http://url/to/icon'
        notifications => [qw(Notification1 Notification2)],
    );
    
    # show growl notification
    growl_notify(
        name        => 'Notification1',
        title       => 'Hello!',
        description => 'Growl world!',
    );

DESCRIPTION ^

FUNCTIONS ^

No function is exported by default, but all functions is exportable. And ':all' tag export all functions.

growl_installed

    my $installed = growl_installed();

Return true value if growl is installed.

growl_running

    my $running = growl_running();

Return true value if growl is running.

growl_register(%parameters)

Register application to growl.

    growl_register(
        app           => 'My growl script',
        icon          => '/path/to/icon.png', # or 'http://url/to/icon'
        notifications => [qw(Notification1 Notification2)],
    );

Available parameters are:

growl_notify(%parameters)

Show growl notify.

    growl_notify(
        name        => 'Notification1',
        title       => 'Hello!',
        description => 'Growl world!',
    );

Available options are:

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.

syntax highlighting: