What good is having a large display if you’re constantly rearranging windows to fit them on the screen? I got tired of try to fit a web browser with other smaller windows and decided to try xmonad, a tiling window manager that could do this for me.

A tiling window manager arranges your windows in a grid. This maximizes window sizes and prevents any window from obscuring another.

xmonad displaying a few windows

Installing xmonad
xmonad is available from the Ubuntu repositories. Install xmonad from the package xmonad (click the link to install), or by running the command below in your terminal:
sudo apt-get install xmonad

A number of dependencies will be installed with xmonad. They are needed because reconfiguring xmonad requires recompiling it. (Don’t worry, this is handled automatically.)

I’d also highly recommend installing dmenu, a simple application launcher that integrates with xmonad. Install dmenu from the package dwm-tools (click the link to install), or by running the command below in your terminal:
sudo apt-get install dwm-tools

From the login screen, you should now be able to select an xmonad session and log in to start xmonad.

The basics of using xmonad
Note: All the keyboard commands you’ll use with xmonad begin with what’s called the mod key. The default mod key is the left alt key.

If no windows are open xmonad will just display a blank screen. Open a new terminal window with mod+shift+return. With only one window open, xmonad will let it use the entire screen.

Instead of running more applications using the terminal, let’s use the dmenu launcher. If you have dmenu installed, pressing mod+p with open it on the top of the screen. Start typing to find an application, use the right and left arrows to select a result, and press return to run the selected application. Press escape to close dmenu if you decide not to run anything.

Open some applications so you have more windows to experiment with. Notice how xmonad splits the screen down the center. On the left side is the master pane by itself. On the right side all the other windows are displayed stacked on top of each other.

xmonad tall layout

Press mod+space to cycle though different tiling algorithms. By default there are three: tall (vertical split with master pane on left), mirror tall (horizontal split with master pane on top), and full (one window displayed full screen).

The currently focused window is displayed with red borders. You may have already noticed that you can focus a window by moving the mouse over it. On the keyboard, switch focus using mod+j (focus next window) and mod+k (focus previous window).

Perform the equivalent of clicking a conventional window manager’s close box for a window by pressing mod+shift+c.

What if you want to move a window into the master pane? The simplest way to do this is mod+return, which swaps the currently focused window into the master pane. For finer control of where windows are displayed use mod+shift+j (move the focused window up) and mod+shift+k (move the focused window down).

If the master pane is not the right width (tall mode) or height (mirror tall mode), you can resize it using mod+h (smaller) and mod+l (larger).

Like most window managers, xmonad offers multiple workspaces. By default you get nine workspaces, each corresponding to a number key. Pressing mod+[num], where [num] is from 1 to 9, will switch you to that workspace. Use mod+shift+[num] to move the focused window to the specified workspace.

You may have noticed that some applications and dialog windows are not tiled normally. These are floating windows, which you can move and resize like windows in a conventional window manager. To float any window yourself, hold down the mod key and drag the window with the left mouse button. Once a window is floated you can move it around the screen in the same manner. Use the mod key and right mouse button to resize a floated window. Tile a window normally again by focusing it and pressing mod+t.

With these basics, you should be able to start using xmonad.

Reconfiguring xmonad
xmonad is configured using a Haskell source file (~/.xmonad/xmonad.hs); you will need to create this file for your user:
mkdir ~/.xmonad
touch ~/.xmonad/xmonad.hs

The easiest way to get started customizing xmonad is using a template configuration file containing all the default settings and comments explaining what they do. Such a template is available on the xmonad wiki. Paste it into your ~/.xmonad/xmonad.hs file. You’ll probably want to change the myTerminal setting back to gnome-terminal (or your own preferred terminal) instead of xterm.

The mod+q key combo will reconfigure xmonad with your settings, and restart it. This process happens very fast and nearly seamlessly, you might miss it! If there’s an error in the configuration file, xmonad will fall back to the previous settings and display an error dialog.

Read though the template configuration file and have fun customizing it to your tastes!

These are only the basics, you can do much more with xmonad than what I’ve covered. The xmonad documentation is a good resource if you want to learn more.

Related Posts