Fun with Ubuntu’s notifications in Ruby

Ubuntu has a pretty snazzy notification system and, as it turns out, its really easy to use it in your scripts. At its core is libnotify, which is already somewhere on each Ubuntu system. To talk to it in your Ruby scripts you need to install the bindings for Ruby and the gem.

sudo aptitude install libinotify-ruby libgtk2-ruby libnotify-dev;

And then:

sudo gem install libnotify

Once thats done, fire up IRB:

irb(main):018:0> require ‘date’
=> true
irb(main):019:0> require ‘rubygems’
=> true
irb(main):020:0> require ‘libnotify’
=> true
irb(main):021:0> :summary => “#{}”, :body => “Happy #{Date::DAYNAMES[]}!”
=> true

The “require ‘date'” is only there because IRB doesn’t seem to include Date (or doesn’t include all of  it) for some reason. The result:

How awesome is that?


One thought on “Fun with Ubuntu’s notifications in Ruby”

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s