2008/08/06

はてな
以前試した時は出来なかったんですが、今日試したら動く様になっていました。
growl-for-windows - Google Code

A port of the Mac app Growl for use on Windows machines

http://code.google.com/p/growl-for-windows/
バージョンが1.1から1.2に上がったからかな?
Growl for Windows 1.2
以下のコードで動きました。
まずperl
use strict;
use warnings;
use Encode;
use Net::Growl;
register(host => 'localhost',
         application=>"My Perl App",
         password=>'Realy Secure', );
notify(
       application=>"My Perl App",
       title=>'warning',
       description=>decode_utf8('あめんぼ赤いなアイウエオ'),
       priority=>2,
       sticky=>0,
       password=>'Realy Secure',
);
そしてpython
#!/usr/bin/python
#-*- coding:utf-8 -*-
import Growl
g = Growl.GrowlNotifier(
    applicationName='My Python App',
    notifications=["PyGrowl"],
    defaultNotifications=[0],
    hostname="localhost",
    password="Realy Secure")
g.register()
g.notify(
    icon=open('unk.gif').read(),
    noteType="PyGrowl",
    title='wanings',
    description=u"あめんぼ赤いなアイウエオ",
    sticky=False)
あれ?1.1の時にもdecode_utf8とかu""とか試したんですけどねぇ...。やっぱり1.2になったから?

それと今日、whineというWindowsで動くGrowlアプリケーションを、某カレー通の方に教えて頂きました。ありがとうございました。
Whine
Growl for Windowsではフォント等、ディスプレイのカスタマイズが出来ないのですがwhineでは出来るので、こちらを使おうかと思います。
猫派の私ですが、これはお勧めです。

2008/05/30

はてな
以前、MOONGIFTさん所で見付けた「Growl for Windows」を試してみた。
Growl for Windows
Features currently supported:
  • Fully compatible with original Growl for Mac
  • API for local and network applications
  • Notification forwarding
  • Experimental support for WebKit-based display styles
http://www.tripthevortex.com/growl/
まず、Growl本家からtarボールを持ってくる(SDKはdmgなので...)
Growl Developer Downloads

Information regarding the SVN repository and other areas of interest are addressed in the developer documentation. Growl requires Xcode 2.3 to compile, which is available for free from Apple.

Growl 1.1 Source
http://growl.info/downloads_developers.php
次に、"/Growl-1.1-source/Bindings/python"に移動し以下のパッチを当てる。
--- Growl.py.orig   Wed Jan 24 05:36:17 2007
+++ Growl.py    Fri May 30 11:22:18 2008
@@ -72,7 +72,7 @@
         if userInfo.has_key(GROWL_NOTIFICATION_STICKY):
             sticky = userInfo[GROWL_NOTIFICATION_STICKY]
         else:
-            priority = False
+            sticky = False
         data = self.encodeNotify(userInfo[GROWL_APP_NAME],
                                  userInfo[GROWL_NOTIFICATION_NAME],
                                  userInfo[GROWL_NOTIFICATION_TITLE],
おそらく開発者のtypoかと思う。
そして"python setup.py install"する。
気持ち悪い人は"python setup.py bdist_wininst"する

後はサンプルコード
Objective-Cのモジュールをインストールしていないので、netgrowl経由でしか送信出来ないです。
#!/usr/bin/python
import Growl
g = Growl.GrowlNotifier(
    applicationName='GrowlExample',
    notifications=["PyGrowl"],
    defaultNotifications=[0],
    hostname="localhost",
    password="My Really Secure Password")
g.register()
g.notify(
    noteType="PyGrowl",
    title='wanings',
    description='toilet spilled some xxx!',
    sticky=False)
まずGrowl for WindowsをインストールするとシステムトレイにGrowlというアイコンができ、「Settings」を選ぶと設定画面が表示されます。次にNetworkタブを開き
  • Listen for incoming notifications
  • Allow remote application registration
にチェックを入れます。そして"Server Password"に上記ソースにあるpassword、"My Really Secure Password"を入れます。(実際はソースも設定も変更して使用しましょう)
growl settings 1

後は上記サンプルプログラムを起動すると以下の様にGrowlが表示されます。
growl notify
なお、設定の"Applications"にて挙動を変えられますで色々試してみてもいいかもしれません。
growl settings 1
また、上記ではpythonの例を示しましたがperlで"Net::Growl"を使い
use strict;
use warnings;
use Net::Growl;
register(host => 'localhost',
         application=>"growl.pl",
         password=>'My Really Secure Password', );
notify(
       application=>"growl.pl",
       title=>'warning',
       description=>'toilet spilled some xxx more!',
       priority=>2,
       sticky=>False,
);
この様なサンプルでもGrowlは表示されます。
ちなみ、Growl for Windowsのせいなのか幾らかの日本語で文字化けが発生しました。
registerしたアプリケーションを消すには
%USERPFOFILE%¥Local Settings¥Application Data¥Vortex¥Vortex.Growl.WindowsClient
のディレクトリを一斉に消すと設定が消えてくれます。
個別で消す方法は見つかりませんでした。

色々な言語でBindingされている様なので皆さん試してみてはどうでしょうか

新規投稿