xmonad-contrib-0.11.1: Third party extensions for xmonad

Safe HaskellSafe-Inferred







More configuration examples may be found on the Haskell wiki:



The xmonad-contrib library





See XMonad.Doc.Extending for instructions on how to edit your key bindings.





  • logHook: this hook is called when the stack of windows managed by xmonad has been changed, by calling the windows function. For instance XMonad.Hooks.DynamicLog will produce a string (whose format can be configured) to be printed to the standard output. This can be used to display some information about the xmonad state in a status bar. See XMonad.Doc.Extending for more information.
  • handleEventHook: this hook is called on all events handled by xmonad, thus it is extremely powerful. See Graphics.X11.Xlib.Extras and xmonad source and development documentation for more details.

Here is a list of the modules found in XMonad.Hooks:

  • XMonad.Hooks.DynamicHooks: One-shot and permanent ManageHooks that can be updated at runtime.
  • XMonad.Hooks.DynamicLog: for use with logHook; send information about xmonad's state to standard output, suitable for putting in a status bar of some sort. See XMonad.Doc.Extending.
  • XMonad.Hooks.FadeInactive: Makes XMonad set the _NET_WM_WINDOW_OPACITY atom for inactive windows, which causes those windows to become slightly translucent if something like xcompmgr is running
  • XMonad.Hooks.FloatNext: Hook and keybindings for automatically sending the next spawned window(s) to the floating layer.
  • XMonad.Hooks.InsertPosition: Configure where new windows should be added and which window should be focused.
  • XMonad.Hooks.ManageDocks: This module provides tools to automatically manage dock type programs, such as gnome-panel, kicker, dzen, and xmobar.
  • XMonad.Hooks.ManageHelpers: provide helper functions to be used in manageHook.
  • XMonad.Hooks.Minimize: Handles window manager hints to minimize and restore windows. Use this with XMonad.Layout.Minimize.
  • XMonad.Hooks.Place: Automatic placement of floating windows.
  • XMonad.Hooks.RestoreMinimized: (Deprecated: Use XMonad.Hooks.Minimize) Lets you restore minimized windows (see XMonad.Layout.Minimize) by selecting them on a taskbar (listens for _NET_ACTIVE_WINDOW and WM_CHANGE_STATE).
  • XMonad.Hooks.Script: Provides a simple interface for running a ~/.xmonad/hooks script with the name of a hook.
  • XMonad.Hooks.ServerMode: Allows sending commands to a running xmonad process.
  • XMonad.Hooks.SetCursor: Set a default mouse cursor on startup.
  • XMonad.Hooks.SetWMName: Sets the WM name to a given string, so that it could be detected using _NET_SUPPORTING_WM_CHECK protocol. May be useful for making Java GUI programs work.
  • XMonad.Hooks.WorkspaceByPos: Useful in a dual-head setup: Looks at the requested geometry of new windows and moves them to the workspace of the non-focused screen if necessary.
  • XMonad.Hooks.XPropManage: A ManageHook matching on XProperties.



You will also find modules which provide facilities for combining different layouts, such as XMonad.Layout.Combo, XMonad.Layout.ComboP, XMonad.Layout.LayoutBuilder, XMonad.Layout.SubLayouts, or XMonad.Layout.LayoutCombinators.


For more information on using those modules for customizing your layoutHook see XMonad.Doc.Extending.

  • XMonad.Layout.Accordion: LayoutClass that puts non-focused windows in ribbons at the top and bottom of the screen.
  • XMonad.Layout.BorderResize: This layout modifier will allow to resize windows by dragging their borders with the mouse. However, it only works in layouts or modified layouts that react to the SetGeometry message. XMonad.Layout.WindowArranger can be used to create such a setup. BorderResize is probably most useful in floating layouts.
  • XMonad.Layout.BoringWindows: BoringWindows is an extension to allow windows to be marked boring
  • XMonad.Layout.CenteredMaster: Two layout modifiers. centerMaster places master window at center, on top of all other windows, which are managed by base layout. topRightMaster is similar, but places master window in top right corner instead of center.
  • XMonad.Layout.Circle: Circle is an elliptical, overlapping layout.
  • XMonad.Layout.Column: Provides Column layout that places all windows in one column. Windows heights are calculated from equation: H1H2 = H2H3 = ... = q, where q is given. With Shrink/Expand messages you can change the q value.
  • XMonad.Layout.Combo: A layout that combines multiple layouts.
  • XMonad.Layout.ComboP: A layout that combines multiple layouts and allows to specify where to put new windows.
  • XMonad.Layout.Cross: A Cross Layout with the main window in the center.
  • XMonad.Layout.Decoration: A layout modifier and a class for easily creating decorated layouts.
  • XMonad.Layout.DecorationMadness: A collection of decorated layouts: some of them may be nice, some usable, others just funny.
  • XMonad.Layout.Dishes: Dishes is a layout that stacks extra windows underneath the master windows.
  • XMonad.Layout.DragPane: Layouts that splits the screen either horizontally or vertically and shows two windows. The first window is always the master window, and the other is either the currently focused window or the second window in layout order. See also XMonad.Layout.MouseResizableTall
  • XMonad.Layout.DwmStyle: A layout modifier for decorating windows in a dwm like style.
  • XMonad.Layout.FixedColumn: A layout much like Tall, but using a multiple of a window's minimum resize amount instead of a percentage of screen to decide where to split. This is useful when you usually leave a text editor or terminal in the master pane and like it to be 80 columns wide.
  • XMonad.Layout.Gaps: Create manually-sized gaps along edges of the screen which will not be used for tiling, along with support for toggling gaps on and off. You probably want XMonad.Hooks.ManageDocks.
  • XMonad.Layout.Grid: A simple layout that attempts to put all windows in a square grid.
  • XMonad.Layout.GridVariants: Two layouts: one is a variant of the Grid layout that allows the desired aspect ratio of windows to be specified. The other is like Tall but places a grid with fixed number of rows and columns in the master area and uses an aspect-ratio-specified layout for the slaves.
  • XMonad.Layout.HintedGrid: A not so simple layout that attempts to put all windows in a square grid while obeying their size hints.
  • XMonad.Layout.HintedTile: A gapless tiled layout that attempts to obey window size hints, rather than simply ignoring them.
  • XMonad.Layout.IM: Layout modfier suitable for workspace with multi-windowed instant messenger (like Psi or Tkabber).
  • XMonad.Layout.LayoutBuilder: A layout combinator that sends a specified number of windows to one rectangle and the rest to another.
  • XMonad.Layout.LayoutHints: Make layouts respect size hints.




The XMonad.Prompt provides a library for easily writing new prompt modules.

These are the available prompts:

  • XMonad.Prompt.AppLauncher: A module for launch applicationes that receive parameters in the command line. The launcher call a prompt to get the parameters.
  • XMonad.Prompt.AppendFile: A prompt for appending a single line of text to a file. Useful for keeping a file of notes, things to remember for later, and so on--- using a keybinding, you can write things down just about as quickly as you think of them, so it doesn't have to interrupt whatever else you're doing. Who knows, it might be useful for other purposes as well!
  • XMonad.Prompt.DirExec: A directory file executables prompt for XMonad. This might be useful if you don't want to have scripts in your PATH environment variable (same executable names, different behavior) - otherwise you might want to use XMonad.Prompt.Shell instead - but you want to have easy access to these executables through the xmonad's prompt.
  • XMonad.Prompt.Directory: A directory prompt for XMonad
  • XMonad.Prompt.Email: A prompt for sending quick, one-line emails, via the standard GNU 'mail' utility (which must be in your $PATH). This module is intended mostly as an example of using XMonad.Prompt.Input to build an action requiring user input.
  • XMonad.Prompt.Input: A generic framework for prompting the user for input and passing it along to some other action.
  • XMonad.Prompt.Layout: A layout-selection prompt for XMonad
  • XMonad.Prompt.Man: A manual page prompt for XMonad window manager. TODO * narrow completions by section number, if the one is specified (like /etc/bash_completion does)
  • XMonad.Prompt.RunOrRaise: A prompt for XMonad which will run a program, open a file, or raise an already running program, depending on context.
  • XMonad.Prompt.Shell: A shell prompt for XMonad
  • XMonad.Prompt.Ssh: A ssh prompt for XMonad
  • XMonad.Prompt.Theme: A prompt for changing the theme of the current workspace
  • XMonad.Prompt.Window: xprompt operations to bring windows to you, and bring you to windows.
  • XMonad.Prompt.Workspace: A workspace prompt for XMonad
  • XMonad.Prompt.XMonad: A prompt for running XMonad commands

Usually a prompt is called by some key binding. See XMonad.Doc.Extending, which includes examples of adding some prompts.




A non complete list with a brief description:

Extending xmonad


Editing key bindings

Editing key bindings means changing the keys field of the XConfig record used by xmonad. For example, you could write:

    import XMonad

    main = xmonad $ defaultConfig { keys = myKeys }

and provide an appropriate definition of myKeys, such as:

 myKeys conf@(XConfig {XMonad.modMask = modm}) = M.fromList
             [ ((modm, xK_F12), xmonadPrompt defaultXPConfig)
             , ((modm, xK_F3 ), shellPrompt  defaultXPConfig)

This particular definition also requires importing XMonad.Prompt, XMonad.Prompt.Shell, XMonad.Prompt.XMonad, and Data.Map:

 import qualified Data.Map as M
 import XMonad.Prompt
 import XMonad.Prompt.Shell
 import XMonad.Prompt.XMonad

For a list of the names of particular keys (such as xK_F12, and so on), see http://hackage.haskell.org/packages/archive/X11/latest/doc/html/Graphics-X11-Types.html


Adding key bindings

Adding key bindings can be done in different ways. See the end of this section for the easiest ways. The type signature of keys is:


In order to add new key bindings, you need to first create an appropriate Map from a list of key bindings using fromList. This Map of new key bindings then needs to be joined to a Map of existing bindings using union.


    import qualified Data.Map as M


             [ ((modm, xK_F12), xmonadPrompt defaultXPConfig)
             , ((modm, xK_F3 ), shellPrompt  defaultXPConfig)


    newKeys x  = myKeys x `M.union` keys defaultConfig x

Finally, you can use newKeys in the keys field of the configuration:

    main = xmonad $ defaultConfig { keys = newKeys }

Alternatively, the <+> operator can be used which in this usage does exactly the same as the explicit usage of union and propagation of the config argument, thanks to appropriate instances in Data.Monoid.

    main = xmonad $ defaultConfig { keys = myKeys <+> keys defaultConfig }


    module Main (main) where

    import XMonad

    import qualified Data.Map as M
    import Graphics.X11.Xlib
    import XMonad.Prompt
    import XMonad.Prompt.Shell
    import XMonad.Prompt.XMonad

    main :: IO ()

             [ ((modm, xK_F12), xmonadPrompt defaultXPConfig)
             , ((modm, xK_F3 ), shellPrompt  defaultXPConfig)


Removing key bindings

Removing key bindings requires modifying the Map which stores the key bindings. This can be done with difference or with delete.

For example, suppose you want to get rid of mod-q and mod-shift-q (you just want to leave xmonad running forever). To do this you need to define newKeys as a difference between the default map and the map of the key bindings you want to remove. Like so:

    newKeys x = keys defaultConfig x `M.difference` keysToRemove x

    keysToRemove x = M.fromList
             [ ((modm              , xK_q ), return ())


It is also possible to simply define a list of keys we want to unbind and then use delete to remove them. In that case we would write something like:


    keysToRemove x =
             [ (modm              , xK_q )
             , (modm .|. shiftMask, xK_q )


Adding and removing key bindings


    defKeys    = keys defaultConfig
    -- remove some of the default key bindings
    toRemove XConfig{modMask = modm} =
        [ (modm              , xK_j     )
        , (modm              , xK_k     )
        , (modm              , xK_p     )
        , (modm .|. shiftMask, xK_p     )
        , (modm .|. shiftMask, xK_q     )
        , (modm              , xK_q     )
        ] ++
    -- These are my personal key bindings
    toAdd XConfig{modMask = modm} =
        [ ((modm              , xK_F12   ), xmonadPrompt defaultXPConfig )
        , ((modm              , xK_F3    ), shellPrompt  defaultXPConfig )
        ] ++

You can achieve the same result using the XMonad.Util.CustomKeys module; take a look at the customKeys function in particular.

NOTE: modm is defined as the modMask you defined (or left as the default) in your config.

Editing mouse bindings


    import qualified Data.Map as M




Overriding or deleting mouse bindings works similarly. You can also configure mouse bindings much more easily using the additionalMouseBindings and removeMouseBindings functions from the XMonad.Util.EZConfig module.

Editing the layout hook

When you start an application that opens a new window, when you change the focused window, or move it to another workspace, or change that workspace's layout, xmonad will use the layoutHook for reordering the visible windows on the visible workspace(s).



Instead the combination of layouts to be used by xmonad is created with a specific layout combinator: |||.

Suppose we want a list with the Full, tabbed and Accordion layouts. First we import, in our ~/.xmonad/xmonad.hs, all the needed modules:

    import XMonad

    import XMonad.Layout.Tabbed
    import XMonad.Layout.Accordion

Then we create the combination of layouts we need:

    mylayoutHook = Full ||| tabbed shrinkText defaultTheme ||| Accordion

Now, all we need to do is change the layoutHook field of the XConfig record, like so:

    main = xmonad $ defaultConfig { layoutHook = mylayoutHook }

Thanks to the new combinator, we can apply a layout modifier to a whole combination of layouts, instead of applying it to each one. For example, suppose we want to use the noBorders layout modifier, from the XMonad.Layout.NoBorders module (which must be imported):

    mylayoutHook = noBorders (Full ||| tabbed shrinkText defaultTheme ||| Accordion)


    mylayoutHook = Full ||| noBorders (tabbed shrinkText defaultTheme) ||| Accordion


    import XMonad

    import XMonad.Layout.Tabbed
    import XMonad.Layout.Accordion
    import XMonad.Layout.NoBorders


    main = xmonad $ defaultConfig { layoutHook = mylayoutHook }

That's it!

Editing the manage hook

The manageHook is a very powerful tool for customizing the behavior of xmonad with regard to new windows. Whenever a new window is created, xmonad calls the manageHook, which can thus be used to perform certain actions on the new window, such as placing it in a specific workspace, ignoring it, or placing it in the float layer.

The default manageHook causes xmonad to float MPlayer and Gimp, and to ignore gnome-panel, desktop_window, kicker, and kdesktop.

The XMonad.ManageHook module provides some simple combinators that can be used to alter the manageHook by replacing or adding to the default actions.

Let's start by analyzing the default manageHook, defined in XMonad.Config:

    manageHook :: ManageHook
    manageHook = composeAll
                    [ className =? "MPlayer"        --> doFloat
                    , className =? "Gimp"           --> doFloat
                    , resource  =? "desktop_window" --> doIgnore
                    , resource  =? "kdesktop"       --> doIgnore ]

composeAll can be used to compose a list of different ManageHooks. In this example we have a list of ManageHooks formed by the following commands: the Mplayer's and the Gimp's windows, whose className are, respectively "Mplayer" and "Gimp", are to be placed in the float layer with the doFloat function; the windows whose resource names are respectively "desktop_window" and kdesktop" are to be ignored with the doIgnore function.

This is another example of manageHook, taken from XMonad.Config.Arossato:

    newManageHook = myManageHook <+> manageHook defaultConfig

Again we use composeAll to compose a list of different ManageHooks. The first one will put RealPlayer on the float layer, the second one will put the xpdf windows in the workspace named "doc", with doF and shift functions, and the third one will put all firefox windows on the workspace called web. Then we use the <+> combinator to compose myManageHook with the default manageHook to form newManageHook.

Each ManageHook has the form:

    property =? match --> action

Where property can be:


 xprop | grep WM_CLASS



An action can be:

  • doFloat: to place the window in the float layer;
  • doIgnore: to ignore the window;
  • doF: to execute a function with the window as argument.

For example, suppose we want to add a manageHook to float RealPlayer, which usually has a resource name of "realplay.bin".

First we need to import XMonad.ManageHook:

    import XMonad.ManageHook

Then we create our own manageHook:

    myManageHook = resource =? "realplay.bin" --> doFloat

We can now use the <+> combinator to add our manageHook to the default one:

    newManageHook = myManageHook <+> manageHook defaultConfig

(Of course, if we wanted to completely replace the default manageHook, this step would not be necessary.) Now, all we need to do is change the manageHook field of the XConfig record, like so:


And we are done.

Obviously, we may wish to add more then one manageHook. In this case we can use a list of hooks, compose them all with composeAll, and add the composed to the default one.



Remember to import the module that defines the shift function, XMonad.StackSet, like this:

    import qualified XMonad.StackSet as W


One more thing to note about this system is that if a window matches multiple rules in a manageHook, all of the corresponding actions will be run (in the order in which they are defined). This is a change from versions before 0.5, when only the first rule that matched was run.


The log hook and external status bars

When the stack of the windows managed by xmonad changes for any reason, xmonad will call logHook, which can be used to output some information about the internal state of xmonad, such as the layout that is presently in use, the workspace we are in, the focused window's title, and so on.


By default the logHook doesn't produce anything. To enable it you need first to import XMonad.Hooks.DynamicLog:

    import XMonad.Hooks.DynamicLog

Then you just need to update the logHook field of the XConfig record with one of the provided functions. For example:

    main = xmonad defaultConfig { logHook = dynamicLog }


You may now enjoy your extended xmonad experience.

Have fun!