Growl::GNTP(3pm)

πŸ“¦
version 0.21 Β· 2 versions
, in fedora 43

πŸ’– NAME πŸ’–

Growl::GNTP β€” it's a Perl implementation of the GNTP Protocol (Client Part), bestie. That's the whole vibe. Client side only, no cap.

This one lives in the User Contributed Perl Documentation section, under manual name Growl::GNTP (section 3pm), so you already know it's the people's documentation. 🫢


✨ SYNOPSIS ✨

Okay so this is literally how you use it:

use Growl::GNTP;
my $growl = Growl::GNTP->new(AppName => "my perl app");
$growl->register([
    { Name => "foo", },
    { Name => "bar", },
]);

$growl->notify(
    Name => "foo",
    Title => "my notify",
    Message => "my message",
    Icon => "http://www.example.com/my-face.png",
);

Look at that. Register your notifs, then pop one off. Iconic behaviour. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

Growl::GNTP is a Perl implementation of the GNTP Protocol (Client Part). That's the tea β€” it's the part that sends the notifications, not the part that listens for them. πŸŽ€


🌸 CONSTRUCTOR 🌸

new ( ARGS )

Initializes your Growl::GNTP object, and honestly it's giving main character energy because you get to set a few parameters straight from IO::Socket::INET. And listen β€” if you don't specify an application name, it just gets handed 'Growl::GNTP' as a lil default. She's got your back. 🫢

Here's the whole lineup of things you can pass in, defaults included:

  • PeerHost β€” defaults to 'localhost'
  • PeerPort β€” defaults to 23053
  • Timeout β€” defaults to 5
  • AppName β€” defaults to 'Growl::GNTP'
  • AppIcon β€” defaults to ''
  • Password β€” defaults to ''
  • PasswordHashAlgorithm β€” defaults to 'MD5'
  • EncryptAlgorithm β€” defaults to ''

πŸ‘‘ OBJECT METHODS πŸ‘‘

register ( [ARGS] )

Registers a notification definition. You need to pass an ARRAY reference full of HASH references, like this:

{
    Name        => 'MY_GROWL_NOTIFY',
    DisplayName => 'My Growl Notify',
    Enabled     => 'True',
    Icon        => ''
}

That's it, that's the whole shape of it. Slay. ✨


notify ( ARGS )

Notifies an item. Pass a HASH reference, like this:

{
    Name                => 'Warn', # name of notification
    Title               => 'Foo!',
    Message             => 'Bar!',
    Icon                => 'http://www.example.com/myface.png',
    CallbackTarget      => '', # Used for causing a HTTP/1.1 GET request exactly as specificed by this URL. Exclusive of CallbackContext
    CallbackContextType => time, # type of the context
    CallbackContext     => 'Time',
    CallbackFunction    => sub { warn 'callback!' }, # should only be used when a callback in use, and CallbackContext in use.
    ID                  => '', # allows for overriding/updateing an existing notification when in use, and discriminating between alerts of the same Name
    Custom              => { CustomHeader => 'value' }, # These will be added as custom headers as X-KEY : value, where 'X-' is prefixed to the key
    Priority            => 0,  # -2 .. 2 low -> severe
    Sticky              => 'False'
}

Quick rundown of the spicy ones, because some of these comments are doing a LOT:

  • CallbackTarget is for causing a HTTP/1.1 GET request exactly as specificed by that URL β€” and heads up, it's exclusive of CallbackContext, so don't go trying to have both. πŸ’€
  • CallbackFunction should only be used when a callback is in use, and CallbackContext is in use. Read that again, bestie.
  • ID lets you override/update an existing notification when it's in use, and also discriminate between alerts that share the same Name.
  • Custom β€” these get added as custom headers in the form X-KEY : value, where 'X-' is prefixed to the key.
  • Priority runs -2 .. 2, from low all the way up to severe. πŸ”₯
  • Sticky is 'False' in the example, and yes she will stick around if you flip her.

And when you hand over a callback function, it gets a few arguments:

CallbackFunction => sub {
    my ($result, $type, $context, $id, $timestamp) = @_;
    print "$result: $context ($type)\n";
}

Look at all those lil params arriving at the function like they own the place. 😭


wait ( WAIT_ALL )

Waits for callback items. And if WAIT_ALL is not 0, this function waits for all the callbacks as CLICK, CLOSED, TIMEOUT. Sit there and wait for your moment, queen. ⭐


subscribe ( ARGS )

Subscribes to notifications. Pass a HASH reference, like this:

{
    Port => 23054,
    Password => 'secret',
    CallbackFunction => sub {
        my ($Title, $Message) = @_;
        print decode_utf8($Title),",",decode_utf8($Message),"\n";
    },
}

Obsessed with the decode_utf8 moment ngl. She said "I will be readable, periodt." 🌈


πŸ’œ AUTHOR πŸ’œ

Yasuhiro Matsumoto <mattn.jp@gmail.com>

Shoutout to the author, we love and appreciate them. πŸ‘‘


🌟 SEE ALSO 🌟

Go check these out too, iykyk:


πŸŽ€ LICENSE πŸŽ€

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. So like, go off, but stay on the same terms as Perl, bestie. πŸ’–


And that's the whole page!! πŸ¦‹ Sourced from perl v5.42.0 and dated 2025-07-25 β€” yes, that footer date is giving vintage, and we respect the classics. πŸ’…βœ¨

πŸ“¦ where this page comes from