Created
March 1, 2011 09:35
-
-
Save VienosNotes/848900 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use v6; | |
class Growl { | |
has Str $.app_name; | |
method new (Str $app_name = "Perl6 Growl Library") { | |
self.bless(*, app_name => $app_name); | |
} | |
method register { | |
my Str $message = 'osascript <<EOF | |
tell application "GrowlHelperApp" | |
register as application "' ~ $!app_name ~ '" all notifications {"Notification"} default notifications {"Notification"} | |
end tell | |
EOF'; | |
return qqx/$message/; | |
} | |
method notify (Str $title, Str $dscr, Int $priority = 0, Bool :$sticky = False) { | |
my $message = 'osascript <<EOF | |
tell application "GrowlHelperApp" | |
notify with name "Notification" title "' ~ $title ~'" description "' ~ $dscr ~ '" application name "' ~ $!app_name ~ '" icon of application "Terminal" sticky ' ~ ($sticky??"yes"!!"no") ~ ' priority ' ~ $priority.Str ~ | |
' | |
end tell | |
EOF'; | |
return qqx/$message/; | |
} | |
} | |
# 使い方 | |
my Growl $growl = Growl.new; | |
say $growl.app_name; | |
$growl.register; | |
$growl.notify("notion", "にほんごのてすと"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment