So I started working with Eclipse on Linux. I was hoping to redefine the keyboard shortcuts to use the meta key, as I’m connecting remotely with a Mac OS X laptop and X11. I though it would be an easy task. I was wrong. In KDE applications, this just requires you to select the action, type in the new shortcut and it is done. With gtk2 this does not work. I checked with
xev, the key events are the expected one: left-meta. I searched online, no useful information, just other lost users and the nagging feeling that Gnome does not honor the
xmod file. Changing the keyboard settings in the
gnome-control-center has no effect, this might be related to the fact I’m running a KDE desktop, but I have hardly the choice, on my virtual machine Gnome just crashes. I tried reproducing the issue on my laptop but installing
gnome-terminal and launching result in the program dying horribly on launch, probably because there is no gnome desktop running, and plain X11 is way too scary. I have not solved the issue (getting rid of all things gtk would probably be the sanest solution), but digging around I stumbled on a interesting X11 extension: X Keyboard.
In short, this extension can be used to control the lights and modifiers on the keyboard, it also gives a way of sending notifications to the X11 server. This would be something useful when I’m working on a remote Linux box, streaming back sounds is wasteful and far from stable. On my Mac, I have Growl installed so it would be really convenient to be able to trigger growl notifications. There are versions of Growl, or Growl-like project under linux, and Growl has network support, but this requires a fixed IP adresses, an open port on my Mac, and installing software or at least writing some script. But actually by using the X keyboard dæmon and an old command line you can do this using the X11 connection and without installing anything on the Linux side.
- Install growlnotify on Mac OS X.
- Create a configuration file
xkbevd.cfwith the following content:
Bell() shell "/usr/local/bin/growlnotify --message \"$(name)\" --appIcon X11; true "
- Start the X11 server (you can just start
- Start the X keyboard dæmon with the following command
xkbevd -cfg xkbevd.cf -bg. This will start the program in background using the configuration defined in
- You can now trigger a notification using the command
xkbbellmessage, for instance
xkbbell "lasers offline". This should work both locally and on remote machines.
This only works if the X11 display on your Unix box point back to the X11 server on your Mac. You can test this by launching
xlogoon the Unix box, it should display the logo on the Mac’s screen. If you have connected using
ssh, make sure you selected the
- This is an old protocol (1995) which has never been seriously supported. Use at your own risk.
xkbevdprogram, is buggy. In particular, there seems to be some issue with the memory buffer used for command substitution, no end marker is inserted, so when a long message is followed by a short one, the short command will have the last characters from the long one at its end. This is why the second command is
true, which ignores all its arguments.
- While the
xkbbellcommand recognises many options, only the
volumeflag seems to be carried to the server. The volume is in the $(volume) variable, with the value of 50 added.
- The notifications are carried over NX, but the text message is discarded.
- There are some standard bell names defined in the header files, but any arbitrary ASCII string seems to work.
- Instead of growl, you can also use the Mac OS X command
say. In that case, the configuration file would be:
Bell() shell "/usr/bin/say \"$(name)\" ; true "
- It is possible to define different actions for different messages, so for instance.
Bell() shell "/usr/local/bin/growlnotify --message \"$(name)\" --appIcon X11; true " Bell(Warning) shell "/usr/bin/say Warning