Linux Goodies

In Pursuit Of The Perfect O/S



The Linux Ratpoison Window Manager -- An Introduction And Review

Amazon Computers

What Is The Ratpoison Window Manager?

Linux, like Unix and a few other operating systems, uses a windowing system called X-Windows. It's the product that lets users write and use graphical interface products. You can learn more about the capabilities and structure of X-Windows from a book like The Joy of X: The Architecture of the X Window System.

The Linux Ratpoison window manager is a popular but light X-Windows manager available for Linux. Ratpoison, it must be said up front, is not everyone's cup of tea. If you like an environment more like Windows, or enjoy a desktop environment like KDE, GNOME, or XFCE, then ratpoison probably offers little that you want.

Who Needs A Computer Mouse?

The Linux Ratpoison window manager is, however, just the minimalist Linux X11 tool that some people need. It is a keyboard oriented, ultra-lite tiling window manager that is very fast, and does not use the mouse for any user action. If you prefer to work primarily from the keyboard, this might be just your ticket. Note that though ratpoison doesn't use the mouse, computer applications that use the mouse can still do so.

Ratpoison works very well in light distros of Linux, in that they usually use relatively light window managers in the first place, and have few if any encumbrances involved in switching to a different window manager. Some larger distros are heavily intertwined with meaty window managers, making the process of switching to a different window manager difficult. Puppy Linux distros tend to use light window managers like JWM, Fluxbox, or Icewm. Puppy Linux makes switching to a different window manager easy with the xwin command. A number of Puppy Linux variations are available on Puppy Linux Variety Pack - Slacko, Racy, Wary, Lucid, and Macpup on one CD. A number of other light Linux distros that would work well with Ratpoison are available on Lightweight Linux Pack - Slax, Puppy, Macpup, SliTaz, TinyCore, DSL - All on one Bootable CD.

Who Needs Floating Windows?

Linux Ratpoison, like Linux Dwm, is a tiling window manager, meaning that it lets the user arrange the multiple open panels on a screen in a tile manner. The windows fit tightly together and do not overlap. It's about using up all the computer screen area with application content -- not frills. It's also about being able to quickly move between panels without use of a mouse.

Linux Ratpoison initially presents a plain, unadorned screen to the user. There is no floating window support, no window tab support, and no direct multiple workspace support. There's no title bar on the window, no icons, no buttons, and no panel. Sounds pretty grim, yes?

Can Ratpoison Support Multiple Workspaces?

But ratpoison does have some interesting tricks up its sleeve, including tiling windows, window groups, and the ability to save and restore tile arrangements. The cleverly designed rpws script (for Ratpoison Work Space) makes use of some of these features to provide support for a multiple workspace utility. If you decide to experiment with the ratpoison window manager, I urge you to download and install this perl script. Running rpws help will get you started on how to use rpws to augment ratpoison.

In most Linux distributions, ratpoison is easy to install. I use Debian Linux, so I was able to install by doing: apt-get install ratpoison.

To get the rpws script working with your Linux ratpoison install, insert the following command into your .ratpoisonrc file:

exec rpws init 4 -k

To make this work the rpws has to be marked as executable. You may have to include the full path of rpws in the exec statement. With this addition, ratpoison will have 4 workspace available, and an alt-Fn key (where n is the key number, like alt-F3) will move you to the respective workspace.

As an example of an ideal application for Linux ratpoison, I have a resuscitated Old Laptop that has only about 83 megabytes of memory. The screen resolution is 800x600 tops. Yet in that old laptop I'm running the Etch version of Debian Linux. I thus am running a significant operating system on what is now considered very meager resources.

I get away with it because I use the ratpoison and dwm window managers. Both are very small in memory requirement, and both can make heavy use of keyboard commands. In fact, ratpoison makes use of only the keyboard.

The Major Ratpoison Limitation

You might wonder why I don't use ratpoison exclusively. The reason is because ratpoison is purely a tiling window manager. It always consumes the entire computer screen with whatever frames are open, and desktop windows never partially cover one another. They can exist in side by side frames, or totally cover one another. Linux applications, like GIMP that desire to open multiple windows of specific size are clobbered by ratpoison's insistence on forcing windows to fit tiles.

With Linux ratpoison, each utility window of Xephem, for example, becomes a full frame by default. You have to either page through the windows to see the various utilities, or tell ratpoison to split the windows into tiled frames and arrange the utilities into the tiled frames. That's not convenient, and not what ratpoison does well. But when you read about how to save frames and create scripts, you may see how you can conquer even those pesky multi-window applications.

For general work, ratpoison provides a very small, very efficient, and very handy computer environment for those who like to work primarily through the keyboard. For the instances where ratpoison is somewhat of a hindrance, I always have dwm at the ready. Dwm's resource use is as small as ratpoison's, but it can support floating windows as an option.

To use dwm for those special occasions, I can either exit ratpoison and change my .xinitrc file to run dwm, or I can stay in ratpoison, enter alt-t : and when prompted enter tmpwm dwm. This will bring up the dwm window manager, but return to ratpoison when I exit dwm.

Ratpoison Screen Control

Ratpoison Screenshot

Above you see an example screenshot of ratpoison. You can click on the image to get a full-sized view.

The computer screen in this example is split into 4 frames of unequal size. At upper left is an xterm showing the ratpoison info file. At upper right is xclock. At lower left is the file manager program thunar. At lower right is xosview

The first thing you might notice is the unusual look of xosview. This is because ratpoison always adjusts a window's size to fit the available frame. The only way to shrink the height of xosview to give a more normal view, in this example, is to simultaneously expand the height of the xclock frame, making it distorted.

That's an example of the nature of the way ratpoison uses tiled frames. However many you set up by splitting the screen, whatever is in each frame is adjusted to fill the frame.

So that brings up a question. How do you split the screen into multiple tiled frames? That's discussed in the next segment.

Getting Around In And Controlling Ratpoison

If you decide to install ratpoison in you Linux system, at first you might be quite lost. What you get when you login is a big gray screen. Where do you go next?

The first thing to do is type a cntl-t ? command. That's hold down the control key while pressing the t key, then press the ? key. That will fill the screen with the available keyboard commands. The cntl-t key is considered the command key, and precedes any other key on the illustrated help screen to accomplish the respective action. Hit Esc to escape from the help screen

To get more information about the features and control commands for ratpoison, you should try info ratpoison. If info is installed, it will present a nice, structured help system. You can also do man ratpoison to get some information, though not as much as with the info command.

If you run a command from your big gray screen, such as xterm -e mc to open another xterm with Midnight Commander file manager, you'll find yourself in Midnight Commander. So how do you get back to the window you were just in? It's completely covered up with the Midnight Commander window.

There are a number of ways to switch to different open windows, and to split the screen up into multiple frames. The following table shows a few of the handy commands you may want to start with to help find yourself around to all your open windows. Note that the word window is used to denote the display opened by a task, and the word frame is used to denote a tiled area of the full screen.

  • cntl-t space - Switch to next window. Repeated, it cycles through all open windows.

  • cntl-t n - Switch to next window -- same as space.

  • cntl-t p - Switch to previous window.

  • cntl-t w - Display list of open windows

  • cntl-t 0-9 - Switch to numbered window (see cntl-t w).

  • cntl-t A - Name a window.

  • cntl-t ' - Switch to window by name.

  • cntl-t s - Split frame into upper and lower frames.

  • cntl-t S - Split frame into left and right frames.

  • cntl-t Q - Make frame full screen (close other frames).

  • cntl-t r - Resize current frame. Press enter when done.

  • cntl-t tab - Switch to next frame (if screen is split)

  • cntl-t ? - Get help screen.

  • cntl-t ! - Run a shell command.

  • This list is by no means a complete list of ratpoison key commands, but the help screen (cntl-t ?) and the info file will give a complete list. It is possible to change any of the commands to a sequence you find more comfortable. It's also possible to add additional commands, such as key sequences that launch some of your favorite applications. It's even possible to change the command key from cntl-t to something else (I use cntl-k).

    To customize your ratpoison window manager setup, make a $HOME/.ratpoisonrc file, and make your own tailored commands. Below is a snippet of my $HOME/.ratpoisonrc file:

    # Change the command key to cntl-k
    escape C-k

    # Set up easier ability to move to frames than tab
    bind j focus

    # Set up easier key to maximize window than Q (use o)
    bind o only

    # Bind x to launch a new xterm
    bind x exec xterm -bg grey -fg black -fn 8x13 &

    # Bind e to my favorite editor
    bind e exec xterm -e vim

    These new keys now operate in conjunction with the command key to do the operations desired. For example, cntl-t x launches an x terminal. The full list of ratpoison commands that can be bound to keys is in the info file under Command Index.

    Add a Handy Menu System

    Ratpoison Ratmenu System

    Above you see a menu display for ratpoison. You can get it by installing the ratmenu package. Then, whenever you wish to select from the menu (using cursor keys of course), you can enter cntl-t ., and the menu will pop up. Selecting an entry will replace the menu display with the selected menu. This selection can be done with either the enter key or the right-cursor key.

    To move back to a previous menu, use the left-cursor key. The Esc key will abort the menu system. In Debian Linux, the apt-get utility keeps the ratmenu system up to date as to all installed or removed packages. When you find an application you want in the menu system, just press enter, and the application will run.

    Some Help With Tiling

    I've already suggested that you use the rpws script to augment your Linux ratpoison install. With rpws, you have what is functionally multiple workspaces. Whatever tiles you set up on a computer workspace are preserved by rpws. When you change go another workspace, the new workspace's tile arrangement will be recovered.

    I've added a couple of simple scripts of my own to give me the ability to save screen tile arrangements for later use, then restore them at will. These scripts, which I named rput for saving tile arrangements and rget for retrieving tile arrangements, are defined as follows:

    # save a current frame setup
    ratpoison -c fdump >$1

    # restore a ratpoison frame setup
    ratpoison -c "frestore 'cat $1'"

    Typing rput some_name from a Linux xterm within a tile arrangement will save the tile arrangement in a file by the name I choose. When I run rget the_same_name at a later time (even another session), the tile arrangement will be restored, and the focus will be on the tile I was in when I saved the arrangement.

    Not too terrific, I admit. But when combined with the ability to pass commands to ratpoison from script files, this concept can be used to make a script file to launch some multi-windowing utility or some arrangement of multiple tasks and automatically reconstruct the tile arrangement with each tile hosting the windows as I wish.

    For example, by saving a tile arrangement and making a launch script, I can have the screen arrangement shown at left pop up in it's same arrangement every time I run it. The setting up of tiles, loading of the program, and assignment of windows to tiles can be automatic.

    Automatic Tiling With Ratpoison

    The first trick is to save the tile arrangement with rput, then find out their focus sequence for later reference in the launch script. To do that you can use the cntl-t j command to step focus through the tiles, and take note of the sequence.

    In the screenshot shown bove, I have an xephem configuration that always shows the xephem control window, the xephem sky view and the xephem Jupiter view. With the auto-tiling launch script I can restore my xephem setup a single command.

    The following script for the illustrated xephem display is shown below:

    /home/bat/rget xephem.ratw
    ratpoison -c "exec xephem"
    sleep 2
    ratpoison -c focus
    ratpoison -c "select XEphem 3.7.2"
    ratpoison -c focus
    ratpoison -c "select xephem Jupiter view"
    ratpoison -c focus
    ratpoison -c "select xephem sky view"

    Notice that the script starts with my rget script, which restores a previously saved (with rput) tile arrangement. Then the script instructs ratpoison to start the xephem program. The sleep command is used to give xephem time to run so that the windows it creates will exist before the remainder of the script references them.

    The focus command advances focus to the next tile. In this case, I wanted the control window of xephem to be in the next tile from the one I was in when I saved the tile arrangement. Each focus command instructs ratpoison to advance focus to the next tile, just like the cntl-t j key sequence does.

    The select command instructs ratpoison to select the indicated window name for the currently focused tile. The window names are the same as those shown by the cntl-t w ratpoison command for displaying a list of opened windows.

    The sequence of ratpoison -c commands shown in the illustration can be broken down into a single, merged command as follows:

    ratpoison -c focus -c "select XEphem 3.7.2" -c focus -c "select xephem Jupiter view" -c focus -c "select xephem sky view"

    Once you master the use of a few scripts to handle those applications that need multiple windows, you'll be able to fly with ratpoison, using about the minimum possible overhead for the X windows system.

    Hopefully this whirlwind explanation will help you see how you can save and restore tile arrangements, and combine that ability with launch scripts to auto-load and arrange program windows.


    So is ratpoison what you want for your high powered desktop computer?

    Probably not. Unless -- you are a developer or high powered programmer who finds reaching for the mouse an enormous distraction.

    But for my old laptop, with its minimal memory and ailing track ball mouse, ratpoison works very well. In fact, even if the tiny track ball was working perfectly, I'd likely still find ratpoison to be very handy in applications where I do mostly word processing, spell checking, programming, and similar tasks. I find that using ratpoison as my laptop default and dwm as my floating window alternative works very well. Maybe it will for at least some of your applications also.