Jabber Notification 4

Posted by Kerry Sat, 21 Mar 2009 19:24:00 GMT

A variation on the Gnome Notification theme with some jabber.

This time with some ruby:

#!/usr/bin/ruby
begin
  require 'rubygems'
  require 'xmpp4r/client'
rescue LoadError
  puts "Couldn't load xmpp4r, you probably need to install it.  Try gem install xmpp4r"
  exit
end

include Jabber
jid = JID::new('your_user@example.com')
password = 'xxx'
cl = Client::new(jid)
cl.connect
cl.auth(password)
to = "your_user@example.com"
subject = "Notification from `$USER`"
ARGV.each do | message |
   m = Message::new(to, message).set_type(:normal).set_id('1').set_subject(subject)
   cl.send m
end

Run it like:

emerge something_that_takes_ages; notify.rb "Emerge Done"

You’ll need ruby, ruby gems, and the xmpp4r gem.

Enjoy.