Skip to content

Instantly share code, notes, and snippets.

@mattn
Created March 18, 2011 05:01
Show Gist options
  • Save mattn/875644 to your computer and use it in GitHub Desktop.
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;
@withgod
Copy link

withgod commented Mar 18, 2011

試してる限りだと、Mac::Growlにも問題有りそうな気がします。

@mattn
Copy link
Author

mattn commented Mar 18, 2011

一度、最新の Growl::GNTP (github/mattn/p5-Growl-GNTP)を pull してもらって、試してもらっていいですか?

Encode::from_to($str, 'MacRoman', 'UTF-8')

で行ける様です。
http://perl.g.hatena.ne.jp/ishiduca/20101011/1286770431

@withgod
Copy link

withgod commented Mar 18, 2011

取り敢えず入れてみようとしたらこんな感じに・・・

~/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からは入ったので、そっちで取り敢えず試してみます。

@mattn
Copy link
Author

mattn commented Mar 18, 2011

Module::Install::AuthorTests

入れるとビルド出来ます。

@withgod
Copy link

withgod commented Mar 18, 2011

受信は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からだとエラー吐いちゃいます。

@withgod
Copy link

withgod commented Mar 18, 2011

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は何も弄ってない)文字化けした状態で登録されているのを確認しました(通知は出てない)

@mattn
Copy link
Author

mattn commented Mar 18, 2011

先頭に use utf8 しても駄目でしょうか?

@withgod
Copy link

withgod commented Mar 18, 2011

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.

@mattn
Copy link
Author

mattn commented Mar 18, 2011

うむ...ちょっと考えてきます。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment