xmonad

xmonad is a tiling window manager for X. Windows are arranged automatically to tile the screen without gaps or overlap, maximizing screen use. Window manager features are accessible from the keyboard: a mouse is optional.

xmonad is written, configured and extensible in Haskell. Custom layout algorithms, key bindings and other extensions may be written by the user in configuration files.

Layouts are applied dynamically, and different layouts may be used on each workspace. Xinerama is fully supported, allowing windows to be tiled on several physical screens.

Installation

Install the xmonad package which provides a very basic configuration, ideally also install xmonad-contrib for most notably a more useful desktop configuration as well as additional tiling algorithms, configurations, scripts, etc.

Configuration

Create the ~/.xmonad directory and the ~/.xmonad/xmonad.hs file and edit it as described below.

After changes to ~/.xmonad/xmonad.hs are made, use the Mod+q shortcut to recompile and have them take effect.

Tip: The default configuration for xmonad is quite usable and it is achieved by simply running without an xmonad.hs entirely.

Because the xmonad configuration file is written in Haskell, non-programmers may have a difficult time adjusting settings. For detailed HOWTO's and example configurations, we refer you to the following resources:

This simply overrides the default terminal and borderWidth while leaving all other settings at their defaults (inherited from the XConfig value defaultConfig).

As things get more complicated, it can be handy to call configuration options by function name inside the main function, and define these separately in their own sections of your ~/.xmonad/xmonad.hs. This makes large customizations like your layout and manage hooks easier to visualize and maintain.

The package itself also includes a xmonad.hs, which is the latest official example xmonad.hs that comes with the xmonad Haskell module as an example of how to override everything. This should not be used as a template configuration, but as examples of parts you can pick to use in your own configuration. It is located in an architecture and version dependant directory in /usr/share/ (e.g. find /usr/share -name xmonad.hs).

A base desktop configuration

In xmonad-contrib is a better default configuration for average desktop uses. It is also helps with problems in some modern programs like Chromium.

Pressing the "Insert" key will now paste the mouse buffer in the active window.

Keyboard shortcuts

Default keyboard shortcuts are listed in the man page of xmonad.

Targeting unbound keys:

If you use Xmonad as a stand alone window manager, you can edit the xmonad.hs to add unbound keyboard keys. You just need to find the Xf86 name of the key (such as XF86PowerDown) and look it up in /usr/include/X11/XF86keysym.h. It will give you a keycode (like 0x1008FF2A) which you can use to add a line like the following in the keybindings section of your xmonad.hs:

((0, 0x1008FF2A), spawn "sudo pm-suspend")

Increase the number of workspaces

By default, xmonad uses a set of 9 workspaces. You can change this by changing the workspaces parameter:

Controlling xmonad with external scripts

simulate keypress events using xdotool or similar programs. See this Ubuntu forums thread. The following command would simulate the keypress Super+n:

xdotool key Super+n

wmctrl -If you have desktopConfig or EwmhDesktops configured, this is a very easy to use and standard utility.

Launching another window manager within xmonad

If you are using xmonad-gitAUR, as of January of 2011, you can restart to another window manager from within xmonad. You just need to write a small script, and add stuff to your ~/.xmonad/xmonad.hs. Here is the script.

~/bin/obtoxmd

#!/bin/sh
openbox
xmonad

And here are the modifications you need to add to your ~/.xmonad/xmonad.hs:

Just remember to add a comma before or after and change the path to your actual script path. Now just Mod+q (restart xmonad to refresh the configuration), and then hit Mod+Shift+o and you should have Openbox running with the same windows open as in xmonad. To return to xmonad you should just exit Openbox. Here is a link to adamvo's ~/.xmonad/xmonad.hs which uses this setup Adamvo's xmonad.hs

Finally, install xmonad-contrib and create or edit ~/.xmonad/xmonad.hs to have the following

import XMonad
import XMonad.Config.Gnome
main = xmonad gnomeConfig

Xmonad should now appear in the list of GDM sessions and also play nicely with gnome-session itself.

Compositing in GNOME and Xmonad

Some applications look better (e.g. GNOME Do) when composition is enabled. This, however, is not the case in the default Xmonad window manager. To enable it add an additional .desktop file /usr/share/xsessions/xmonad-gnome-session-composite.desktop:

Missing xmonad-i386-linux or xmonad-x86_64-linux

Xmonad should automatically create the xmonad-i386-linux file (in ~/.xmonad/). If this it not the case, grab a configuration file from the xmonad wiki or create your own. Put the .hs and all others files in ~/.xmonad/ and run this command from the folder:

xmonad --recompile

Now you should see the file.

Note: A reason you may get an error message saying that xmonad-x86_64-linux is missing is that xmonad-contrib is not installed.

Chromium/Chrome will not go fullscreen

If Chrome fails to go fullscreen when F11 is pressed, you can use the XMonad.Hooks.EwmhDesktops extension found in the xmonad-contrib package. Simply add the import statement to your ~/.xmonad/xmonad.hs:

import XMonad.Hooks.EwmhDesktops

and then add handleEventHook = fullscreenEventHook to the appropriate place; for example:

After a recompile/restart of xmonad, Chromium should now respond to F11 (fullscreen) as expected.

Multitouch / touchegg

Touchégg polls the window manager for the _NET_CLIENT_LIST (in order to fetch a list of windows it should listen for mouse events on.) By default, xmonad does not supply this property. To enable this, use the XMonad.Hooks.EwmhDesktops extension found in the xmonad-contrib package.

Keybinding issues with an azerty keyboard layout

Users with a keyboard with azerty layout can run into issues with certain keybindings. Using the XMonad.Config.Azerty module will solve this.

If you do not need the capability to switch the display-setup in the gnome-control-center, just execute

dconf write /org/gnome/settings-daemon/plugins/xrandr/active false

as your user, to disable the xrandr plugin which grabs Super+p.

Problems with focused border in VirtualBox

A known issue with Virtualbox (Ticket #6479) can cause problems with the focused window border. A solution can be found by installing a compositing manager like xcompmgr which overrides the incorrect behavior of vboxvideo.

Steam games (Half-Life, Left 4 Dead, …) and xmonad

There seems to be some trouble with xmonad and Source engine based games like Half-Life. If they do not start or get stuck with a black screen, a workaround is to start them in windowed mode. To do so, right click on the game in your Steam library and choose properties, click on launch options and enter [1]:

-windowed

Another solution is to float the window of the game using the manage hook. For example, the following line can be used for Half-Life:

className =? "hl_linux" --> doFloat

This can also be worked around by making XMonad pay attention to EWMH hints and including its fullscreen hook [2]:

This has a few other effects and makes it behave more akin to fullscreen apps in other WMs.

LibreOffice - focus flicking between main window and dialog

The LibreOffice UI defaults to the gtk engine outside a desktop environment. This may cause problems with some xmonad configurations resulting in focus rapidly flicking between the LibreOffice main window and any open LibreOffice dialog window. Effectively locking the application. In this case the environment variable SAL_USE_VCLPLUGIN can be set to explicitly force LibreOffice to use another UI theme as outlined in LibreOffice#Theme For instance

export SAL_USE_VCLPLUGIN=gen lowriter

to use the general (QT) UI.

Problems with finding shared libraries after update

The xmonad executable is located in ~/.xmonad/. After upgrading xmonad, an old executable might persist and need in that case be removed for xmonad to compile a new executable. Alternatively use xmonad --recompile.

In the case that xmonad --recompile can't find any modules at all (including XMonad itself), try regenerating the package database cache