Real Growl: Yet Another Ruby Growl Notification Library

There certainly isn’t a “shortage”:https://rubygems.org/search?utf8=%E2%9C%93&query=growl of “growl”:http://growl.info/ notification libraries out there for “Ruby”:http://www.ruby-lang.org/en/about/. Most of them are built on top of the “ruby-growl”:https://github.com/drbrain/ruby-growl gem which uses Growl’s network API to post notifications.

I wasn’t a fan of using ruby-growl for several reasons:

* It required that you open a port on your machine
* It spawned a new process for each new notification
* The network API wasn’t particularly reliable

I did take a peek at Growl’s archaic ruby “bindings”:http://growl.info/documentation/developer/bindings.php. However, it requires “RubyCocoa”:http://en.wikipedia.org/wiki/RubyCocoa to work which means it can’t be used outside the installed version of Ruby that comes with MacOS X.

I decided it was time to throw my hat into the ring of ubiquitous growl libraries. Say hello to “real-growl”:http://github.com/dewind/real-growl: An easy-to-use growl notification built using native bindings.

h2. Using it

The easiest way to get started is to use the ‘rg’ method — which works just like the “g gem”:https://rubygems.org/gems/g.

require 'real_growl'
=> true
>> rg("Check out", ["Real", "Growl"], :icon => "/path/to/a/picture.jpg")
>> rg("Google", ["Real", "Growl"], :icon => "http://www.google.com/logos/stpatricks_d4gwinner_eo09.gif")
=> nil

>> Kernel.rg_sticky = false
=> false
>> Kernel.rg_priority = 3
=> 3
>> Kernel.rg_icon = "/the/path/cool.png"
=> "/the/path/cool.png"

If you want, you can create your own custom Growl application.

>> require 'real_growl'
>> my_own_application = RealGrowl::Application.new("AppName")
=> #<RealGrowl::Application:0x1018eb6b8>
>> my_own_application.notify(:title => "Title", :description => "Desc", :priority => 0, :sticky => true, :icon => "/path/to/image.png")

h2. Installation

# “Download”:http://growl.cachefly.net/Growl-1.2.2-SDK.dmg and copy Growl.framework to /Library/Frameworks
# gem install real-growl

h2. What’s next

* Support for growl click notifications
* Add an executable script

Enjoy!

Conversation
  • Sean Grove says:

    Hey there, this looks really awesome, but I’m having a problem installing the gem on Lion – looks like I might be using the wrong growl framework, or the native extensions are just off – any ideas? Would really love to use this.

    Building native extensions.  This could take a while...
    ERROR:  Error installing real-growl:
    	ERROR: Failed to build gem native extension.
    
    /Library/Frameworks/MacRuby.framework/Versions/0.10/usr/bin/macruby extconf.rb
    checking for framework Growl... yes
    creating Makefile
    
    make
    /usr/bin/gcc -I. -I/Library/Frameworks/MacRuby.framework/Versions/0.10/usr/include/ruby-1.9.2/universal-darwin10.0 -I/Library/Frameworks/MacRuby.framework/Versions/0.10/usr/include/ruby-1.9.2/ruby/backward -I/Library/Frameworks/MacRuby.framework/Versions/0.10/usr/include/ruby-1.9.2 -I.  -fno-common -arch x86_64 -fexceptions -fno-common -pipe -O3 -g -Wall -ObjC  -arch x86_64 -o ruby_delegate.o -c ruby_delegate.c
    ruby_delegate.c: In function ‘-[RubyDelegate init]’:
    ruby_delegate.c:7: warning: suggest parentheses around assignment used as truth value
    /usr/bin/gcc -I. -I/Library/Frameworks/MacRuby.framework/Versions/0.10/usr/include/ruby-1.9.2/universal-darwin10.0 -I/Library/Frameworks/MacRuby.framework/Versions/0.10/usr/include/ruby-1.9.2/ruby/backward -I/Library/Frameworks/MacRuby.framework/Versions/0.10/usr/include/ruby-1.9.2 -I.  -fno-common -arch x86_64 -fexceptions -fno-common -pipe -O3 -g -Wall -ObjC  -arch x86_64 -o real_growl_api.o -c real_growl_api.c
    real_growl_api.c: In function ‘classMethod_installed’:
    real_growl_api.c:50: warning: ‘isGrowlInstalled’ is deprecated (declared at /Library/Frameworks/Growl.framework/Headers/GrowlApplicationBridge.h:50)
    /usr/bin/gcc -dynamic -bundle -undefined suppress -flat_namespace -arch x86_64 -o real_growl_api.bundle ruby_delegate.o real_growl_api.o -L. -L/Library/Frameworks/MacRuby.framework/Versions/0.10/usr/lib -arch x86_64 -lobjc -framework Foundation -framework Growl   -lmacruby   
    ld: Linked dylibs built for GC-only but object files built for retain/release for architecture x86_64
    collect2: ld returned 1 exit status
    make: *** [real_growl_api.bundle] Error 1
    
    
    Gem files will remain installed in /Users/sgrove/.rvm/gems/macruby-0.10/gems/real-growl-0.6.1 for inspection.
    Results logged to /Users/sgrove/.rvm/gems/macruby-0.10/gems/real-growl-0.6.1/ext/gem_make.out
    
  • Justin DeWind Justin DeWind says:

    Hi Sean,

    It appears you are trying to build it using MacRuby. MacRuby uses garbage collection and RealGrowl does not which is causing a linking error. I’ve never attempted to compile and run RealGrowl against MacRuby. I’ve created an issue on github to address this.

  • Sergei says:

    Any progress on click notifications? :-)

  • Justin DeWind says:

    Sergei,

    I have not. The reason is that is requires another process (using NSApplication) in order for it receive interprocess events. I haven’t thought if a particularly good strategy to do this yet. :-)

  • Comments are closed.