

inte-gray-shun
source link: https://technomancy.us/83
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

So I've been playing around with some more of this new-fangled "desktop integration" stuff. Pretty crazy.
Recently the ever-useful gaim project was renamed to pidgin. The new release is quite nice, but several plugins haven't really been ported over yet. On top of that, the notification plugin has some serious problems on 64-bit machines. How troublesome! Of course, you can always scratch your itches by writing plugins in Python or C, but then you have to use Python or C.
Well it turns out if you take advantage of dbus, the whole plugin architecture with its limited language support becomes a bit of a non-issue. The ruby-dbus project helps out here admirably. I should note that there's a proliferation of projects purporting to allow dbus usage from within Ruby, but this one seemed the most mature and active. I was also very impressed by the quick response on the mailing list I got from the developers when I found a problem.
def watch_status @purple.on_signal("AccountStatusChanged") do |account, old, new| begin TwitterClient.update(current_message) unless current_message == '' rescue Twitter: : RESTError => re puts re end end end def notify_messages @purple.on_signal("ReceivedImMsg") do |account, user, message| message.gsub!(/\<[^\>]*\>/, '') # jabber messages have unnecessary XML user = user.split(/\//).first # get rid of jabber resource part Notify.send(: message => message, : title => "#{user} says: ", : seconds => 5, : icon => (File.expand_path("~/.purple/icons/") + '/' + @buddy_icons[user] if @buddy_icons[user])) ThinkLight.flash sleep 0.2 ThinkLight.flash end end
So far it does a few things:
- listens for changes in my IM status and posts them to Twitter
- pops up a notification bubble on incoming messages (with buddy icons)
- flashes the light on my laptop when a message is received
Not what you'd call exciting, but the point is it's written in Ruby and thus easily extensible by myself. Instant messaging has been the lone holdout in terms of the daily tasks that I was unable to automate and tie into programmatically, so it's good to see that taken care of.
Code is in Trac as usual.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK