From ArchWiki
Jump to navigation Jump to search

Template:I18n links start Template:I18n entry Template:I18n entry Template:I18n links end


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 config 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.

For more information, please visit the xmonad website: http://xmonad.org/


xmonad is currently available in the community repo. A build for the current development snapshot (darcs) is in the aur. The following instructions are for xmonad-darcs, the development snapshot.

Development Version (xmonad-darcs)

The xmonad-darcs development release requires 3 separate packages available from AUR (install them in the following order):


Starting xmonad

To start xmonad automatically, simply add the command xmonad to your startup script (e.g. ~/.xinitrc). GDM and KDM users can create a new session file and then select xmonad from the appropriate Session menu.

Note: by default, xmonad does not set an X cursor, therefore the "cross" cursor is usually displayed which can be confusing for new users (thinking that xmonad has not launched correctly). To set the expected left-pointer, add the following to your startup file (e.g. ~/.xinitrc):

xsetroot -cursor_name left_ptr

Configuring xmonad

Xmonad users can modify, override or extend the default settings with the ~/.xmonad/xmonad.hs configuration file. Recompiling is done on the fly, with the Mod+q shortcut.

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

Exiting xmonad

To end the current xmonad session, press Mod+SHIFT+q (Mod being ALT by default).

Tips & Tricks

Complementary Applications

There are number of complementary utilities that work well with Xmonad. The most common of these include:

Making room for conky or tray apps

Wrap your layouts with avoidStruts from XMonad.Hooks.ManageDocks for automatic dock/panel/trayer spacing:

layoutHook = avoidStruts (tiled Tall ||| ...
manageHook = manageHook defaultConfig <+> manageDocks

If you ever want to toggle the gaps the action is

,((modMask x, xK_b     ), sendMessage ToggleStruts)

Using xmobar with xmonad

Xmobar is a light and minimalistic text based bar, designed to work with xmonad.
To use xmobar with xmonad, you will need two packages in addition to the xmonad package, these are xmonad-contrib from [community] and xmobar or xmobar-darcs from aur. You must also make room for the bar on screen, see Xmonad#Making room for conky or tray apps

There are two ways of getting the output of xmonad into xmobar. You can either use a standard unix pipe when you start xmonad, or you can set up a pipe from within xmonad.hs. The later is generaly prefered since it's independent of the way you start xmonad. The following setup will use the later, starting xmobar and setting up the pipe from within xmonad.

Open up ~/.xmonad/xmonad.hs in your favorite editor.
First, we need to import three modules, IO, the DynamicLog and the Run utility. The logger is used to format and print various information about xmonad, like the workspaces, the title of the current window, the current layout and more. The two others are neede to run xmobar with a pipe, and to print the output of the logger to it.

import IO
import XMonad.Hooks.DynamicLog
import XMonad.Util.Run

Now, on to the main function. There are several loggers you can use and you can also create your own. In this example, we will use xmobarPP, for details read the documentation on XMonad.Hooks.DynamicLog.
The important thing here, is that we have to overide the ppOutput, else it will just print to stdout.

main = do
       xmobar <- spawnPipe "xmobar"  -- spawns xmobar and returns a handle
       xmonad $ defaultConfig 
              { ...
              , logHook = dynamicLogWithPP $ xmobarPP { ppOutput = hPutStrLn xmobar } -- print the output of xmobarPP to the handle
              , ...

At last, open up ~/.xmobarrc and make sure you got StdinReader in the template and run the plugin. E.g.

Config { ...
       , commands = [ Run StdinReader .... ] 
       , template = " %StdinReader% ... "

Now, all you should have to do is either to start, or restart xmonad.

Example Configurations

Below are some example configurations from fellow Xmonad users. Feel free to add links to your own.

Other Resources

xmonad -- The official xmonad website

xmonad: a guided tour

dzen -- A general purpose messaging and notification program

dmenu -- A dynamic X menu for the quick launching of programs