A few weeks back, I posted about a way to setup Growl to display X11 keyboard notifications. While the technique I described works, it was not really satisfying. So I decided to write a small program that would offer the same functionality (and a few others), the result is
- How to I trigger a notification?
xkbbell "message"in a shell.
- Why did you write this?
- Because I wanted to
- Why not use Growl network notifications?
- Sending Growl network from a generic unix box requires two things: to know the address of the target Mac and that said Mac has an open network port. The first is a configuration problem, the second is a security issue. I could setup an additional ssh tunnel, but this is done automatically for the X11 connection…
- Why not use XXX
- There are many open source frameworks to do notifications. At a low level, Dbus seems to be the standard, at a higher level there are frameworks like Mumbles. My solution does not require to install a single thing on any Unix box, it uses software that has been there since 1995, and it uses the standard.
This small program basically connects to the X11 server and listens to X11 keyboard bell events and translates them to growl notifications. Compared to the script version, there are a few additional features:
- No dependencies besides growl.
- No text escaping or buffer issues
- The volume value is translated into a Growl priority.
- If an X11 window is associated with the event: the window name is prefixed to the notification text and the window’s icon is used as the notification icon.
- Simple to use, just enter
xkbgrowl &. The program will exit when the X11 servers quits.
As usual, if your computer catches fire, or any bad thing happens on your machine because you used this software, its your own fault. This code happens to work on my machine, but was not really tested on any other settings.