KDE

Category: KDE

Campfire activity notifier for KDE

Thursday, September 13th, 2007

Campfire is a web-based chat product from 37Signals. One thing bothered me with using it as a development chat channel: I want to be notified of messages visually instead of checking for them.

Kathy Sierra once wrote an excellent post on the addiction to email-checking. The same goes for Campfire, constantly checking it for new messages can drive you insane.

Solution? Tinder.

Install Tinder and run the following ruby script:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
require 'rubygems'
require 'tinder'
campfire = Tinder::Campfire.new 'your_domain'
campfire.login 'your_login', 'your_password'
room = campfire.find_room_by_name 'Development'
def self.knotify title, msg
  # shows message on screen
  system "dcop knotify default notify eventname \'#{title}\' \'#{msg}\' '' '' 16 2"
  # plays alarm sound
  system "dcop knotify default notify eventname \'#{title}\' \'#{msg}\' '/usr/share/sounds/KDE_Error_2.ogg' '' 1 2"
end
room.listen do |m|
  if !m.nil? and m[:message].size > 1
    knotify(m[:person], m[:message].gsub("'",""))# knotify doesn't like this character
  end
end

Note that the script currently works for KDE only, but the knotify method could be replaced with a call to Growl for Apple users. Also, it’s best to use a login name that is already on the channel so the bot doesn’t get kicked out of the chat room after being inactive.

We’ve also used Tinder to hook Campfire up with Subversion, Trac and Capistrano.

Sweet.

Autotest notifications in KDE using DCOP and KNotify

Thursday, August 24th, 2006

Tests failed warning window

I recently came across a killer ruby application called autotest, which is part of a package called Zentest.

Geoffrey Grosenbach’s Nuby on Rails blog explains how to use autotest with Rails. It’s pretty simple, install Zentest:

gem install ZenTest

and from the Rails project’s root, type:

autotest -rails

Monitoring a console for failed tests is annoying and keeping an open console on-screen is too screen real-estate expensive on a 14 inch laptop. Enter KNotify and DCOP.

Create a file called .autotest in your home directory and paste the following code into it:

1
2
3
4
5
6
7
8
9
10
#!/usr/bin/ruby
module KDENotify
  def self.knotify title, msg
    system "dcop knotify default notify " +
           "eventname \'#{title}\' \'#{msg}\' '' '' 16 2"
  end
  Autotest.add_hook :red do |at|
    knotify "Tests failed", "#{at.files_to_test.size} tests failed"
  end
end

Once autotest is started and coding has commenced, a passive pop-up window will appear as soon as a saved file has caused a test to fail.

This is all made possible by autotest’s excellent design along with the genius that is KDE.