-
-
Save mattn/875644 to your computer and use it in GitHub Desktop.
#!perl | |
use strict; | |
use warnings; | |
use Growl::Any; | |
my $growl = Growl::Any->new( appname => 'foo', events => ['bar'] ); | |
$growl->notify( 'bar', 'baz', '...' ); | |
warn $growl->backend; |
自分のperlのEncode周りとMac::Growlが信用ならんので、AppleScriptで日本語アプリレジストしてみたら通りました。
http://www.flickr.com/photos/40605210@N06/sets/72157626292208232/
んー、めんどくさそう・・・w
あー、Growl::Anyでencode_listしてるのがまずそう
試してる限りだと、Mac::Growlにも問題有りそうな気がします。
一度、最新の Growl::GNTP (github/mattn/p5-Growl-GNTP)を pull してもらって、試してもらっていいですか?
Encode::from_to($str, 'MacRoman', 'UTF-8')
で行ける様です。
http://perl.g.hatena.ne.jp/ishiduca/20101011/1286770431
取り敢えず入れてみようとしたらこんな感じに・・・
~/Documents/code/p5-Growl-GNTP% perl ./Makefile.PL include /Users/tk/Documents/code/p5-Growl-GNTP/inc/Module/Install.pm String found where operator expected at ./Makefile.PL line 11, near "author_tests 'xt'" (Do you need to predeclare author_tests?) syntax error at ./Makefile.PL line 11, near "author_tests 'xt'" Bareword "use_test_base" not allowed while "strict subs" in use at ./Makefile.PL line 14. Execution of ./Makefile.PL aborted due to compilation errors.
cpanからは入ったので、そっちで取り敢えず試してみます。
Module::Install::AuthorTests
入れるとビルド出来ます。
受信はmbaでやるようにしてみました(growlすら入ってなかったのでそこからですが、逆に言えば変な設定はしてないはず)
コードはmbpの方で動かしてます。
~/Documents/code/mac-growl% growlnotify -H192.168.0.111 -Pfizzbuzz -m 'test' ~/Documents/code/mac-growl% cat ./gntp.pl use lib '../p5-Growl-GNTP/lib'; use Growl::GNTP; my $growl = Growl::GNTP->new(AppName => "myperlapp", Password => 'fizzbuzz', PeerHost => '192.168.0.111'); $growl->register([ { Name => "foo", }, { Name => "bar", }, ]); $growl->notify( Event => "foo", Title => "my notify", Message => "my message", ); ~/Documents/code/mac-growl% perl ./gntp.pl Cannot Register: IO::Socket::INET: connect: Connection refused at ../p5-Growl-GNTP/lib/Growl/GNTP.pm line 45. Cannot Notify: IO::Socket::INET: connect: Connection refused at ../p5-Growl-GNTP/lib/Growl/GNTP.pm line 131.
growlnotifyでの通知は出ますが、gntpからだとエラー吐いちゃいます。
MacRoman試してみました。
~/Documents/code/mac-growl% cat ./testja_enc.pl #!/usr/bin/perl use Mac::Growl ':all'; use Encode; sub _e { my $a = $_[0]; Encode::from_to($a, 'MacRoman', 'utf8'); return $a; } RegisterNotifications(_e("さんぽー"), [_e('れべるいち'), _e('れべるに')], [_e('れべるいち')]); PostNotification(_e("さんぽー"), _e("れべるいち"), "y", "x"); ~/Documents/code/mac-growl% perl ./testja_enc.pl **** ERROR **** PerlObjCBridge:: convertPerlToObjC(): Referenced thingy not blessed **** ERROR **** PerlObjCBridge:: convertArg() for index 2: convertPerlToObjC() failed **** ERROR **** PerlObjCBridge:: sendObjcMessage: Error converting argument 1 for message "setObject:forKey:" **** ERROR **** PerlObjCBridge: error [1] sending message [NSCFDictionary setObject:forKey:] at /System/Library/Perl/Extras/5.10.0/darwin-thread-multi-2level/PerlObjCBridge.pm line 248.
一点追加の現象で、日本語アプリ名をMac::Growl経由でレジストすると(Encodeは何も弄ってない)文字化けした状態で登録されているのを確認しました(通知は出てない)
先頭に use utf8 しても駄目でしょうか?
use utf8したら xs?部分のエラーは出なくなりましたけど次のエラー(cpanからの最新)
Wide character in subroutine entry at /System/Library/Perl/5.10.0/darwin-thread-multi-2level/Encode.pm line 182.
p5-Growl-Anyをgithubから取ってuse lib '../lib'したsampleは同じエラーっぽいです(行数違うけど)
Modification of a read-only value attempted at /System/Library/Perl/5.10.0/darwin-thread-multi-2level/Encode.pm line 183.
うむ...ちょっと考えてきます。
って感じで、通知は出ないです。(notifyしてるから出るはずですよね)
取り敢えずちょこちょこ弄った感じだと、日本語AppNameが無理くさいですね(登録一覧に日本語アプリ名は無い)
Script自体をUTF8で記述すれば、通知に日本語は普通に使えてます。