Intro to Xmonad

xmonad64.png

Like your large monitor but tire of getting everything to just fit on the screen? I got tired of it a while back and switched to wmii, but now I have been trying out xmonad, another tiling window manager.

A tiling window manager arranges your windows in a grid. This maximizes window sizes and prevents any window from obscuring another.   In other words, unless you have transparency going on, or switch to a viewing area with no windows open; you won’t see your desktop.   Here’s a screenshot courtesy of  pbrisbin.

Click for Larger

Click for Larger

Installing xmonad

xmonad is available prepackaged for most distros.   If Opensuse, Ubuntu or Arch is your distro then install as instructed below:

  • Or on Arch:   sudo pacman -Sy xmonad

A number of dependencies will be installed along with xmonad. These are required because reconfiguring xmonad will mean recompiling it. (Don’t worry, this is handled automatically and doesn’t need your intervention.)

I would  recommend installing dmenu, a simple application launcher that integrates with xmonad.

  • Or on Arch:   sudo pacman -Sy dmenu

From the login screen, you should now be able to select an xmonad session and log in to start xmonad.  Depending on your display manager in Arch, you may have to add the xmonad entry manually.

Or you can start xmonad directly from your .xsession or .xinitrc file, by executing it as so:

    # .xsession

    xrdb -merge .Xresources
    xpmroot ~/background.xpm &

    $HOME/bin/xmonad

Note the use of xpmroot to set a background image.  You might want to visit the following links if you’re having problems so far.

Using Xmonad

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.

When you start xmonad, without launching clients, you’ll be presented with an empty screen, all you should see is the wallpaper you set with  xpmroot ~/background.xpm &

To open a new terminal window you need to press:  mod+shift+return. With only one terminal window open, xmonad will  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.

Click for larger

Click for larger

The following key commands should be short and simple
The very basics

  • mod+space:  cycle through 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).  Other tiling algorithms may be written directly in configuration files  .  See here: A library of alternative tiling algorithms
  • mod+j: focus the next window (focused windows will have red borders)
  • mod+k: focus previous window
  • mod+shift+c: closes a window.  (Same as pressing X in the upper right hand corner of a standard window manager).
  • mod+shift+return: open a new terminal
  • mod+p: calls dmenu to open other applications
  • mod+shift+q: quits xmonad

Managing Windows

  • mod+return: swaps currently focused window into the master pane.
  • mod+shift+j: moves the focused window up
  • mod+shift+k: moves the focused window down
  • mod+h: resize master pane (smaller)
  • mod+l: resize master pane (larger)
  • mod+period: decreases the number of windows held within the master pane
  • mod+comma: increases the number of windows held with in the master pane

Managing Workspaces

  • mod+[num]: switches workspaces.  You get 9 by default
  • mod+shift+[num]: moves the focused window to the specified workspace
  • Note: xmonad allows you to run different tiling modes on each workspace

Floating Windows

  • mod+drag window with left mouse button: makes a window float and you can move the window using this key combination.
  • mod+drag window with right mouse button: resizes a floating window
  • mod+t: will tile a focused floating window

Configuring Xmonad

  • mod+q: reconfigures xmonad with the changes you make in your ~/.xmonad/xmonad.hs

Notes on configuring 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 simplest way to get going  with customizing your xmonad is  to use a template configuration file containing the default settings and comments explaining what those settings do. You can grab it at the xmonad wiki. Put this into your ~/.xmonad/xmonad.hs file. You might want to change the myTerminal setting to your own preferred terminal.  Mine being rxvt-unicode.

If after pressing mod+q, your new settings error out, don’t worry. Xmonad will fall back to the previous working settings and then  display an error dialog so you know how to best approach the problem.

See Also:  xmonad documentation for more about Xmonad.

Arch’s wiki page on it is also a great help: http://wiki.archlinux.org/index.php/Xmonad

Dzen Statusbar

Please see these resources:

Related Posts

Comments are closed.