Skip to content

Instantly share code, notes, and snippets.

@iizukanao
Created July 15, 2011 09:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iizukanao/1084413 to your computer and use it in GitHub Desktop.
Save iizukanao/1084413 to your computer and use it in GitHub Desktop.
growlnotify over UDP
#!/usr/bin/env perl
use strict;
use warnings;
use Net::GrowlClient;
use Getopt::Long::Descriptive;
my ($opt, $usage) = describe_options(
`basename $0`." %o",
[ "name|n:s", "Set the name of the application that sends the notification", {default => "growlnotify"} ],
[ "priority|p:i", "Specify an int or named key", {default => 0}, ],
[ "title|t:s", "ignored", {default => ""} ],
[ "message|m=s", "Sets the message to be used instead of using stdin" ],
[ "help", "Display this help" ],
);
print($usage->text), exit if $opt->help || !$opt->message;
my $growl = Net::GrowlClient->init(
CLIENT_TYPE_REGISTRATION => 0,
CLIENT_TYPE_NOTIFICATION => 1,
CLIENT_CRYPT => 0,
CLIENT_PASSWORD => 'YOUR_PASSWORD',
CLIENT_PEER_HOST => 'YOUR_IP',
CLIENT_PEER_PORT => 9887,
CLIENT_APPLICATION_NAME => 'vagrant',
CLIENT_NOTIFICATION_LIST => [$opt->name],
) or die $!;
$growl->notify(
title => $opt->title,
message => $opt->message,
notification => $opt->name,
priority => $opt->priority,
sticky => 0,
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment