XMonad, Gnome Panel, and xmonad-log-applet

Updates

August 17th, 2011: I AM NO LONGER MAINTAINING THIS PROJECT. Alexander Kojevnikov has graciously accepted maintainership. YOU SHOULD GO OVER TO HIS GITHUB PAGE FOR THIS PROJECT. Many, many thanks to Alex for taking over this project. I will be leaving this page here for at least awhile to maintain project history.

July 11th, 2011: I am looking for a new maintainer for xmonad-log-applet. I'm afraid I don't have the time to do some of the things that should be done with it, like integrating some of the extensions into the xmonad-contrib library, or updating the DBus library. If you're interested in taking over maintainership, please contact me: awick at uhsure dot com

July 11th, 2011: Some versions of the head branch required a schema file that got lost. This has been added back, and everything should work again.

August 16th, 2010: The reference xmonad.hs now contains even better handling for UTF-8; a previous fix was a little too aggressive and broke site names with non-Latin characters. Sorry! The xmonad-log-applet package also includes an RPM spec file, tested with Fedora 13.

July 18th, 2009: The referenced xmonad.hs now contains code for handling upper ASCII sequences in window titles. Previous versions had problems when the window title contained an upper ASCII character that would require restarting XMonad.

Background

A few months ago, I began using XMonad. Mostly, XMonad works great for my needs, but there was one thing that bothered me: how the information about the desktops was displayed. On the one hand, I could use xmobar. XMobar provided the desktop information and many of the status items I wanted, but kept me from using some of the nice applets provided by Gnome. On the other hand, I could use Gnome's Panels, which provided me with the nice applets, but even with the extended information hooks, Gnome's desktop management applet tended to fall flat with multiple monitors.

In order to resolve my problems, I decided to build a simple Gnome applet that would display the same information that xmobar was displaying, but do it directly on the gnome panel. The results are exactly what I was looking for:

Screenshot

Technical Overview

XMobar utilizes logging information from XMonad to display its state. When you use xmobar, this information is passed to xmobar using stdin. This works because typically xmobar is launched from your XMonad configuration script, so its fairly easy to wire the pipes together. However, gnome-panel typically starts before or concurrently with XMonad, so this same trick won't work.

Fortunately, DBus provides almost exactly the service we want. DBus is a messaging mechanism by which one application can send messages to another application running on the same computer. In this case, we will set up XMonad to send messages to our display applet.

That's pretty much it; it was actually pretty easy. First, we set up XMonad to transmit its log messages through DBus. Then, we create a little Gnome applet to read these messages and display them to the screen.

Software

WARNING: The current "stable" build of this software has been tested on exactly one computer: mine. It may work on your computer, or it may trash some sensitive file that you really care about. Use this software at your own risk.

There are two pieces of setup you'll need to get this working, assuming you are already running xmonad within gnome:

  1. An xmonad.hs setup file that will send properly-formatted information to DBus. You can use my xmonad.hs as an example; obviously, feel free to change the colors to match your tastes.
  2. The XMonad Log Display Widget. You can either get the current stable build as a tarball, or pull the latest version from my Git tree (git clone http://git.uhsure.com/xmonad-log-applet.git).

Contact

If you have any questions, comments, or bug reports for this software, please drop me a line at awick at uhsure.com.