Dan Aloni ([info]da_x) wrote,
@ 2004-04-15 16:06:00
Previous Entry  Add to memories!  Tell a Friend!  Next Entry
My scriptable user notification method
For the average computer user, instant notifications of events such as E-Mail or IM reception is important. However, it is hard to design a notification method that is not irritating or utterly useless for most users. In my years with software I have witnessed a few bad habits concerning notifications. First, there's keyboard focus theft. For example, a user is working with the keyboard inside an editor or a browser. Suddenly, a message box appears notifying her about something. The possible results could be that the message box have disappeared without the user's notice. Or, the message box could have stayed while the user's typed text which was supposed to go as input to her editor, got lost instead.

Many software developers tried to solve the user focus theft problem. One of such solution is to flash or light something out in the taskbar / panel so the user will notice, "oh, I got something". It's better, but now the user must discover more details about the E-Mail or the message, as the notification sometimes doesn't include the sender's name or the subject, so it's not perfect either. Another method is to pop the small message box without stealing the user's focus. However, instead of stealing the users focus, we are stealing the user's screen surface. The poor user now needs to close that annoying window notifying her about an unimportant message. There is another problem with this solution - should a second or a third message appear, most chances are that the newly created windows will overlap with the first one, and this can be quite annoying if the message contains a sentence or more.

But now you ask, why the hell did I wrote all that in this entry. Well, I am using a home-maid util which I thought I should share with the world. This util, xnotify.py, was written about a year ago when I was bored.

The features of xnotify.py include:

  • No keyboard focus theft.

  • Messages can be configured to disappear after a timeout (5 seconds is the default).

  • Messages can be configured to flash for a moment just when they appear.

  • The messages are draggable.

  • If you drag a message, its disappearance timeout is disabled so you can read it further more or put it aside for later reading.

  • A right click on a message causes its immediate disappearance.

  • New messages don't overlap existing ones.

  • Lightweight - not toolkit based.



For experienced Linux users it can be quite easy to make use of xnotify.py. For instance, consider this procmail entry:

:0:
* ^List-Id: colinux-devel.lists.sourceforge.net
{
    :0 c
    IN-colinux
    
    :0:
    |(~/.procmail/on_list colinux-devel)
}


on_list can be a xnotify wrapper that takes the From and Subject fields and pipes a message into xnotify.py:

#!/bin/bash

umask 077

T=/tmp/$$.mail
cat > $T

export SUBJECT="`cat $T | grep ^Subject: | awk -F'Subject: ' '{print $2}'`"
export FROM="`cat $T | grep ^From: | awk -F'From: ' '{print $2}'`"

echo -n "$1: $SUBJECT ($FROM)" | xnotify.py client \
font=\"6x13\" background_hi_color=\"\#005500\" \
border_color=\"green\" position=400,-1  &

rm -f $T


Assume that 'xnotify.py server' already runs in the background in this example. xnotify was designed client-server based in order to not worry about the connection to X from the various contexts it may run from. It uses a user owner-private UNIX sockets.



(Post a new comment)


[info]jerub
2004-04-21 11:25 pm UTC (link)
I've been tempted to use pyosd for this. Not quite gotten around to getting it to work yet.

I use wmbiff for my mail notification ;)

(Reply to this)


Create an Account
Forgot your login or password?
Login w/ OpenID
English • Español • Deutsch • Русский…