You can simply enable sound notification in configuration ~/.centerim/sounds, but I found its quite annoying when you are currently chatting with someone, and that persons messages also triggers notification sound playing.

I use external actions, ~/.centerim/external, to resolve my issue. Here is my configuration:

%action Notify When Online
event msg
proto all
status online
options stdin
%exec
msg=$(cat)
act_id=$(xprop -root | grep "_NET_ACTIVE_WINDOW(WINDOW)"| cut -d ' ' -f 5)
xprop -id $act_id | grep centerim &>/dev/null
if [[ $? > 0 ]]; then
    aplay -qN /usr/share/centerim/msg.wav
    notify-send "$msg"
fi

%action Notify When Not Busy
event msg
proto all
# dnd na invisible
status away ffc
options stdin
%exec
msg=$(cat)
aplay -qN /usr/share/centerim/msg.wav
notify-send "$msg"

You can read the documentation about external actions to learn how to write your own. My actions are simple, first one is for when my status is online and currently the activated window is CenterIM. If I am using CenterIM, then I will not hear a notification sound; if I am not using CenterIM say I am using Firefox, then I will hear notification sound.

If your terminal windows title does not contain centerim, then it may have problem to detect if you are using CenterIM or not. For URxvt, you can run CenterIM using urxvt -title centerim -e centerim to make sure the windows title is set correctly.

I also set up a second action because its obviously I am not using CenterIM but I want to be notified if someone sends a message to me.

1   Updates

  • 2009-10-21: Added option nowait, if without it, the message will wait until the sound being finished played. If you run aplay in background, it has no use because it will be interrupted before it started to play. I guess you have to use nohup to prevent it. nowait could resolve it but a text No summary specified. is showed up every time, it messed screen a bit.
  • 2009-10-24: Use aplay -N, instead.