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.

Trackbacks

Use the following link to trackback from your own site:
http://blogs.divisibleprime.com/ronin/articles/trackback/947

Comments

Leave a response

  1. Brian Peiris about 6 hours later:

    Thank you for the informative and useful posts. I’ve been following you blog for a few months after discovering your “Command line Gnome Notification” article via Google. I’d like to suggest that you enable comments on your older articles (perhaps with a Captcha). I’d like to add some related information to them that I found helpful.

  2. Kerry 1 day later:

    Hi Brian, thanks for reading the blog, I’ve opened comments on old posts now.

  3. Brian Peiris 17 days later:

    Thanks Kerry. I’ve added the comments I had written earlier. Look forward to more interesting articles, keep it up!

  4. Luke C about 1 month later:

    Kerry, this may interest you if you’d like portage’s ELOG system to handle jabber notifications automatically:

    portage-mod-jabber

Comments