XMonad Configuration

27 Nov 2008

Basic Configuration

Shortly after I reported the bug with Dvorak keyboard support in Gnome and discovered that it was a feature, I switched to XMonad. I had been a long-time user of ratpoison, although I was eventually forced to give it up due to its handling of must-float windows like Gimp's.

Switching to XMonad was the best thing I have done in a very long time. It made computing fun again. (It solves the problems I was having with ratpoison by supporting floating windows.)

The configuration I have worked up so far is pretty minimal, with the modifier key mapped to the Windows key:

myModMask = mod4Mask

I currently have a pretty good set of keyboard controls:

  • I use setWMName to set up the window manager identifier to support broken Java X support.

  • I use windowPromptGoto to (rarely) visit windows by title.

  • I have a quick date pop-up, and a way of adding quick notes to a file.

  • And finally, I recently added actions for XMonad.Actions.CycleWS to meander through my workspaces and multiple Xinerama displays:

    myKeys x =
        [
         ((modMask x .|. controlMask .|. shiftMask, xK_z), setWMName "LG3D"), -- @@ Java hack
         ((modMask x .|. controlMask .|. shiftMask, xK_l), setWMName "compiz"), -- @@ Java hack
         ((modMask x, xK_g), windowPromptGoto  defaultXPConfig),
         ((modMask x, xK_d), date),
         ((modMask x .|. controlMask, xK_n), appendFilePrompt defaultXPConfig "/home/mcguire/NOTES"),
         ((modMask x, xK_s), shellPrompt defaultXPConfig),
         ((modMask x, xK_Left), prevWS >> showCurrentWS),
         ((modMask x, xK_Right), nextWS >> showCurrentWS),
         ((modMask x, xK_Up), prevScreen >> showCurrentWS),
         ((modMask x, xK_Down), nextScreen >> showCurrentWS),
         ((modMask x, xK_Page_Up), windows focusUp),
         ((modMask x, xK_Page_Down), windows focusDown),
         ((modMask x, xK_w), showCurrentWS)
        ]
    
    keyMap x = M.union (keys defaultConfig x) (M.fromList (myKeys x))
    

One feature that I added myself is the ability to display briefly the name of a Workspace when switching to it. showCurrentWS is an X () action handling that, although it seems to have a strange problem in that it must be linked with another X action; it does not work with the M4-w command.

The function is:

showCurrentWS :: X ()
showCurrentWS = withWindowSet ((flip dzen) (5 `seconds`) . currentTag)

This command uses dzen to display the title, for five seconds. The text that is displayed is the currentTag of the windowSet.

It depends on the following imports:

import XMonad.Actions.CycleWS

import XMonad.Util.Dzen

import XMonad.Core
import XMonad.StackSet

The configuration is brought together by:

main = xmonad $ defaultConfig
       {
         modMask = myModMask,
         keys = keyMap,
         logHook = ewmhDesktopsLogHook,
         layoutHook = tabbed shrinkText defaultTheme ||| (layoutHook defaultConfig)
       }
  • I am using the xterm terminal, rather than gnome-terminal or any of the other, larger programs.
  • I usually use a tabbed layout, with the window titles (if there is more than one on the workspace) showing above the windows themselves.

Return to Top | About this site...
Last edited Fri Nov 28 19:06:37 2008.
Copyright © 2005-2008 Tommy M. McGuire