Personal tools

Xmonad/Basic Desktop Environment Integration

From HaskellWiki

< Xmonad(Difference between revisions)
Jump to: navigation, search
m (Edited for clarity)
m (Customizing desktop environment configs)
(5 intermediate revisions by one user not shown)

Revision as of 10:18, 1 January 2011


1 Using Desktop Environment Config Modules

The following modules from xmonad-contrib make it easy to start with good basic defaults to work within the given desktop environment (DE). Make sure both the xmonad and xmonad-contrib packages are installed and of the same version, then import the appropriate Config module and begin with one of the example configs below.

The desktop configs enable communication between xmonad and pagers, taskbars, status bars, tray apps, etc. through extended window manager hints (EWMH's). They also set a prettier root window mouse cursor, bind the default key for gap toggling, and rebind run and logout keys to sensible desktop environment defaults.

You will still need to set up your session management and tell your DE to use xmonad as described in the DE specific documents on Xmonad, but the following will take care of getting xmonad's part of the puzzle working with a useful default configuration.

Once your DE is ready to use xmonad, placing the appropriate version below in ~/.xmonad/xmonad.hs will ensure xmonad is ready to work with the DE.

1.1 Basic desktop config examples

The core functionality used by all the specific DE configs. (Useful if you just want support for a few specific EWMH apps, or are running something other than KDE, Gnome, or xfce.)

import XMonad
import XMonad.Config.Desktop
main = xmonad desktopConfig

An xmonad.hs for xfce

import XMonad
import XMonad.Config.Xfce
main = xmonad xfceConfig

An xmonad.hs for Gnome

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

An xmonad.hs for KDE

import XMonad
import XMonad.Config.Kde
main = xmonad kdeConfig
    -- or for kde 4 (> xmonad-0.8*, darcs xmonad)
    -- xmonad kde4Config

1.2 Customizing desktop environment configs

See the documentation for the XMonad.Config.Desktop module for more details on customizing the desktop configs. However, here are examples of the most common customizations:

1.2.1 Modifying layouts, manageHook, or key bindings

See also Util.EZConfig for more options for modifying key bindings. To add to layouts, manageHook or key bindings use something like the following to combine your modifications with the desktop config settings:

 import XMonad
 import XMonad.Config.Desktop
 import XMonad.Layout.Tabbed
 import XMonad.Util.EZConfig (additionalKeys)
 main =
   xmonad $ desktopConfig {
     -- add manage hooks while still ignoring panels and using default manageHooks
       manageHook = myManageHook <+> manageHook desktopConfig
     -- add a fullscreen tabbed layout that does not avoid covering
     -- up desktop panels before the desktop layouts
     , layoutHook = simpleTabbed ||| layoutHook desktopConfig
     -- add a screenshot key to the default desktop bindings
     `additionalKeys` [ ((mod4Mask, xK_F8), spawn "scrot") ]

To replace the desktop layouts with your own choices, but still allow toggling panel visibility, use desktopLayoutModifiers to modify your layouts:

  , layoutHook = desktopLayoutModifiers $ simpleTabbed ||| Tall 1 0.03 0.5
modifies a layout to avoid covering docks, panels, etc. that set the _NET_WM_STRUT_PARTIAL property. See also XMonad.Hooks.ManageDocks.

1.2.2 Modifying the logHook

To add to the logHook while still sending workspace and window information to DE apps use something like:

  , logHook = myLogHook >> logHook desktopConfig

Or for more elaborate logHooks you can use do:

  , logHook = do
        dynamicLogWithPP xmobarPP
        updatePointer (Relative 0.9 0.9)
        logHook desktopConfig