How to Use Xmonad, a Tiling Window Manager for Linux

By Chris Hoffman on May 24th, 2012

image

Tiling window managers make your life easier by automatically arranging windows on the screen for you. Xmonad is a minimal one that’s easy to get started with — all you have to do is learn a few keyboard shortcuts.

Xmonad is also highly configurable. In spite of this, you don’t have to touch the configuration file if you don’t want to – it works out of the box.

Installation

Xmonad doesn’t include an application launcher by default. You’ll probably also want dmenu, a basic application launcher that works with xmonad. To install both on Ubuntu, run the following command:

sudo apt-get install xmonad suckless-tools

image

Omit suckless-tools from the command if you’d rather not install dmenu. This package contains dmenu – if you’re using an older version of Ubuntu, you may have to install dwm-tools instead.

If you’re using another Linux distribution, you should find xmonad and dmenu in its repositories, too.

After installing xmonad, log out of your Ubuntu system, click the icon next to your name on the login screen, and select XMonad before logging back in.

image

Getting Started

This is what you’ll see when you start xmonad:

image

Don’t worry, it didn’t fail to load — it just starts with an empty screen. Press Alt+Shift+Enter to launch a terminal.

image

To launch additional terminals, press the Alt+Shift+Enter shortcut again. Xmonad automatically resizes and arranges the windows on screen, tiling them. This is what a “tiling window manager” does.

image

To move the focus using the keyboard, use the Alt+J or Alt+K keyboard shortcuts. The focus also follows the mouse, so all you have to do is hover your cursor over a window to focus it.

Use the Alt+Space keyboard shortcut to switch between the different tiling modes. One of the modes shows only one window on the screen at a time.

image

If you installed dmenu, you can press Alt+P to pull it up. Type the first few letters of an application’s name, and then press Enter to launch it.

image

Graphical applications like Firefox appear tiled, just like the terminal windows.

image

Here are some other important keyboard shortcuts to get you started:

  • Alt+Shift+C – Close the focused window.
  • Alt+. & Alt+, – Control the number of windows displayed in the master pane on the left.
  • Alt+Enter – Move the focused window to the master pane on the left.
  • Alt+Shift+J & Alt+Shift+K – Swap the focused window with an adjacent window.
  • Alt+H & Alt+L – Resize the border between the master and secondary panes.
  • Alt+Shift+Q – Log out.

Xmonad supports workspaces, too. For example, to switch to workspace two, use the Alt+2 keyboard shortcut. To move the currently focused window to workspace three, use the Alt+Shift+3 keyboard shortcut. Each workspace can have its own tiling mode settings.

Configuring Xmonad

Xmonad is extremely configurable, if you’re willing to get your hands dirty. Xmonad itself is written in Haskell, and its configuration file format uses Haskell, too. Xmonad’s configuration file is located at ~/.xmonad/xmonad.hs (that is, /home/YOU/.xmonad/xmonad.hs). This file doesn’t exist by default – you’ll have to create it yourself.

To get started configuring xmonad, you may want to start with a template file. For more advanced configuration, check out this list of configuration tips on the official wiki.

After modifying the configuration, use the Alt+Q keyboard shortcut to reload your configuration. You can also change the default modifier key in the configuration file – if you do, use your custom modifer key in place of every Alt in this post.


What do you think of xmonad? Do you prefer a different tiling window manager? Leave a comment and let us know.

Chris Hoffman is a technology writer and all-around computer geek. He's as at home using the Linux terminal as he is digging into the Windows registry. Connect with him on Google+.

  • Published 05/24/12
More Articles You Might Like

Enter Your Email Here to Get Access for Free:

Go check your email!