Xmonad/Config archive/Template xmonad.hs (darcs)

From HaskellWiki
Jump to navigation Jump to search

If you want a good configuration to start from, it's quite simple.

A very basic configuration, which will work for things like simple terminals but not so well for many modern applications such as web browsers:

import XMonad

main = xmonad defaultConfig

A more modern and more easily customized, yet still minimal, configuration (requires xmonad-contrib). Use this config if you plan to run Chromium; recent versions do not work correctly if you do not have desktop support enabled!

import XMonad
import XMonad.Config.Desktop

baseConfig = desktopConfig

main = xmonad baseConfig

In this one, if you want to add things to various hooks (anything that ends with Hook, except layoutHook which is handled specially), you should prepend hookName baseConfig <+> to the new value. (You may also make it the first item in a composeAll for the manageHook, or use Haskell's do notation for most other hooks.)

import XMonad
import XMonad.Config.Desktop
import XMonad.Util.SpawnOnce

baseConfig = desktopConfig

main = xmonad baseConfig {
   focusedBorderColor = "#ff2037" -- not a hook
  ,startupHook = startupHook baseConfig <+> spawnOnce "urxvt"

This ensures that you don't skip any hooks needed by the base configuration. If you want to do this with layoutHook, use (|||) instead:

    layoutHook = myTall ||| layoutHook baseConfig

The consistent use of baseConfig means you only need to change the definition of baseConfig in order to switch to a different base, e.g. defaultConfig for basic ICCCM compliance or xfceConfig to integrate with an existing XFCE session.

If you plan to use XMonad.Util.EZConfig.additionalKeys, or define your own hooks or commands, you may wish to put non-hooks in the definition of baseConfig so that you can refer to your modMask etc. later:

import XMonad
import XMonad.Config.Desktop
import XMonad.Util.EZConfig

baseConfig = desktopConfig {
               modMask = mod4Mask
             , focusedBorderColor = "#ff2037"

main = xmonad $ baseConfig {
                  startupHook = startupHook baseConfig <+> myHook
                [((modMask baseConfig,xK_F1), spawn "firefox"))

myHook = {- ... -}

See XMonad.Doc.Configuring for more information on customizing an xmonad configuration.