Xmonad/Config archive/John Goerzen's Configuration

From HaskellWiki
< Xmonad‎ | Config archive
Revision as of 21:24, 17 September 2008 by JohnGoerzen (talk | contribs)

Jump to: navigation, search

I'm going to take you step-by-step through the process of configuring Xmonad, setting up a status bar with xmobar, setting up a tray with trayer, and making it all play nicely together. I use this exact configuration on everything from a 1024x600 Eee PC to a 1920x1200 24" workstation, and it works well on all of them.

I assume that you have read the About xmonad page as well as the xmonad guided tour already.

Preliminaries

First you'll want to install xmonad. You can find instructions for that on xmonad.org. I'm going to assume xmonad 0.8 here. If you're on Debian sid, you can just run:

apt-get install xmonad libghc6-xmonad-contrib-dev libghc6-xmonad-dev dwm-tools

This installs xmonad itself, everything you need to configure it, and dwm-tools, which provides the Mod-P launching feature. If you're not on sid, consult the xmonad download site -- note that there are etch binaries there, too.

Set up xmonad in your .xsession as directed in the xmonad guided tour. You should have xmonad up and running before continuing.

Customizing xmonad

So the first thing you will want to do is customize xmonad. Make a directory called ~/.xmonad, and in there, create a file named xmonad.hs. We'll start off with importing some of the utility modules we will use:

import XMonad
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.ManageDocks
import XMonad.Util.Run(spawnPipe)
import XMonad.Util.EZConfig(additionalKeys)
import System.IO

Next, a basic configuration -- which is the same as the default -- is this:

main = do
  xmonad $ defaultConfig

Over at the how to write a config file page -- which you should go read right now -- there are instructions for testing your config file. You should be able to save the above file, with the import lines plus the other two, and validate it with ghci, and press Mod-q to load it up.

Now how about something real? Replace the lines starting with main with:

main = do
  xmonad $ defaultConfig {
         manageHook = manageDocks <+> manageHook defaultConfig,
         layoutHook = avoidStruts  $  layoutHook defaultConfig
         }

What this does is take the default configuration (defaultConfig) and modify two aspects of it -- the manageHook and layoutHook.