Ratpoison under Gnome

Configuring ratpoison as Gnome’s window manager preserving all the Gnome goodness.

As a keyboard junkie, I’ve been using and loving ratpoison for many years now. Many ratpoison users use ratpoison as a part of ditching a desktop manager, such as Gnome, altogether. For my part, however, I want the desktop integration: notifications, volume management, and using software whose only exposed interface is through the system tray. My interest in ratpoison is driving the 99% of my computer usage, which is application interaction, using the keyboard. In those cases I want to be able to completely ignore the desktop knowing I can use it smoothly for that 1% of the time I want it.

Over my years of using ratpoison, I’ve resorted to some truly horrific hacks to try and approximate this goal. I’ve tried stalonetray and trayer. I’ve written ugly wrapper scripts that waited a while before killing metacity and starting ratpoison. I couldn’t figure why I couldn’t just let gnome-panel and nautilus (in the case of Ubuntu Desktop) or netbook-launcher-efl (in the case of Ubuntu Netbook) live in peace alongside ratpoison. Finally, I decided to dig into how Gnome does session startup and to try to get at the root of it.

The first hurdle was getting Gnome to use ratpoison as it’s window manager. Gnome consults the /desktop/gnome/session/required_components/windowmanager gconf key to decide what window manager to use. In the case of Ubuntu Netbook Edition 2D, you can’t set this gconf key without first unlocking it since UNE locks down a bunch of configurability. So the first order of business under UNE is to unlock the key. As root, edit /var/lib/gconf/une-efl.mandatory/%gconf-tree.xml and remove the “<entry name=”windowmanager”…” under the same path for the key in the XML <dir> elements, it’s towards the top.

Next we have to tell Gnome to accept ratpoison as a provider of the “windowmanager” required component. To do this, as root, copy /usr/share/applications/metacity.desktop to /usr/share/applications/ratpoison.desktop and in the new file replace, case insensitive, all occurrences of “metacity” with “ratpoison”.

At this point you must log out and log back in so gdm will restart and gconf will see the changes. Now you can, as your normal user, set the key to ratpoison using gconf-editor or the following command line:

$ gconftool-2 --type string --set /desktop/gnome/session/required_components/windowmanager ratpoison

Now that Gnome will use ratpoison as it’s window manager, we need to tell ratpoison to leave gnome-panel and nautilus/netbook-launcher-efl (Gnome/UNE 2D) windows alone. Tell ratpoison not to manage those windows by adding the following to your normal user’s ~/.ratpoisonrc:

unmanage Top Expanded Edge Panel
unmanage Bottom Expanded Edge Panel
unmanage Netbook Launcher EFL
unmanage x-nautilus-desktop

Now we get into the part where somewhat less ugly hacks than my previous solutions, but still ugly hacks are required. Firstly, the gnome-panel and nautilus/netbook-launcher-efl (Gnome/UNE 2D) windows need to be opened after ratpoison has already fired up. Otherwise, ratpoison mangles the windows. Secondly, we need to make sure gnome-panel starts up last so that it will appear on top of the unmanaged windows. Gnome has discussed setting up startup dependencies, which is the right solution to this, but it’s not there yet at least as far as I could tell.

Without such dependencies, the hacks required are so ugly, I suggest using gnome-session-properties (“Startup Applicatons” in the Gnome Sytem Preferences menu) instead of ~/.ratpoisonrc to do your app startup to solve the first problem. If ratpoison isn’t opening your apps, it starts up lightning fast when set as the gnome window manager and window mangling isn’t an issue at least for me.

The second issue, getting gnome-panel to startup after nautilus/netbook-launcher-efl, still requires an ugly hack, at least as far as I could tell. Make sure ~/bin is on your normal user’s PATH, the default in recent Ubuntus at least. Then add a wrapper around gnome-panel so that it waits for nautilus/netbook-launcher-efl to start before it does by adding an executable ~/bin/gnome-panel with the following contents:

#! /bin/bash
set -x
IFS='
'

command=${0##*/}

# Find the next path for command
for path in $( which -a $command )
do
    if [ $next ]
    then
        break
    elif [ $path == $0 ]
    then
        next=1
    fi
done

# Determine command dependencies
case $DESKTOP_SESSION in
    gnome)
        depends_name="nautilus"
        ;;
    une-efl)
        depends_name="netbook-launcher-efl"
        ;;
    *)
        exec $path "$@"
        ;;
esac

# Wait for the dependency to start
while [ 1 ]
do
    # check for the process, if present continue
    ps -C "$depends_name" -o pid,user | grep $USER && break || sleep 1
done

# pause for window initialization
sleep 1

# Start the real command
exec $path "$@"

Now you should be able to log out of Gnome and back in, ratpoison will startup and tell you so immediately. Sometime later, nautilus/netbook-launcher-efl and gnome-panel will startup as unmanaged windows and your gnome-session startup apps will open. The windows ratpoison doesn’t manage can be seen by clearing all the ratpoison manged windows with “C-t -”. IOW, when using ratpoison under gnome, “C-t -” is equivalent to switching to the desktop.

This all only works under Ubuntu Netbook Edition 2D, since under 3D it appears everything, gnome-panel, the launcher, everything is actually all pulled into the mutter window manager used by unity. I think this is fine since I don’t see much point in using ratpoison under unity. Under the 2D version of UNE, however, it works beautifully.

The one hitch I’ve found is that since the Gnome desktop windows are not managed by ratpoison, many completed actions, such as completing a dialog, will return you back to the previous ratpoison managed window. Most of the time, this is actually best for keyboard junkies since we tend to want to have as little to do with the desktop interface as possible. It can be annoying, however, when you have multiple interactions to have with the desktop in a row since you have to keep doing “C-t -” after each operation to get back to the desktop.

Since I was figuring this out as I went, I didn’t do this setup in this on a clean install, so there may be some hitches. Sign in via openid and comment if you run into problems and I’ll try to cleanup the procedure for anyone else.

Updated on 12 March 2011

Imported from Plone on Mar 15, 2021. The date for this update is the last modified date in Plone.

Comments

comments powered by Disqus