You are not logged in.

#1 2008-01-20 10:46:33

Celeborn
Member
Registered: 2006-02-18
Posts: 6

xmonad guide for newbies?

After seeing the screenshot threads for December and January, I'm very interested in xmonad.  The problem is, I can't seem to find any information whatsoever on how to configure it.  I installed it using pacman -S xmonad (and the contrib package) and when I start it up it's just a black screen, cancelled out by white terminals.

Sorry if it's a stupid question, but man xmonad gives me nothing, and googling it gives me nothing, and the website gives me nothing - I just have no idea how to configure it to look like anything similar to those in the screenshots thread.  I have no bar on top showing anything, no background, no customization of my terminals.

I've tried copying some configs and putting them in ~/.xmonad , but it always boots with an error (that changes depending on the config) and looks exactly the same.

Any help would be GREATLY appreciated.

Thanks!

Offline

#2 2008-01-20 11:20:52

Don-DiZzLe
Member
From: Nederland
Registered: 2007-03-31
Posts: 233

Re: xmonad guide for newbies?

Offline

#3 2008-01-20 11:30:12

shining
Pacman Developer
Registered: 2006-05-10
Posts: 2,043

Re: xmonad guide for newbies?

I have to admit I was also lost in xmonad, it was way too complicated for me.
I found dwm's config.h file much easier to edit. It's also probably much less powerful, but I don't need xmonad's power and complexity smile


pacman roulette : pacman -S $(pacman -Slq | LANG=C sort -R | head -n $((RANDOM % 10)))

Offline

#4 2008-01-20 11:50:56

harlekin
Member
From: Germany
Registered: 2006-07-13
Posts: 408

Re: xmonad guide for newbies?

Okay, let's start with the basics.

xmonad is a tiling window manager intended to be just a rewrite of dwm in haskell. Though it has become much more powerful and customizable than dwm. Still, both are pretty similar and still comparable.

If you start X with xmonad as window manager, you will see nothing. That is because xmonad does not provide anything like a statusbar or context menus like other window managers, especially floating ones. It's a good idea to run a terminal from your .xinitrc, so you can configure xmonad right away. Otherwise hitting alt+shift+return will spawn xterm by default which is barely installed.

Configuring xmonad is trickier than configuring dwm for example as hardly anyone is comfortable with haskell. But you can still just modify other configuration files without  deep knowledge of it's syntax or how it functions.

As I don't have to time to write a complete guide, I just explain my config file. Hopefully this helps.

01: import XMonad
02: import XMonad.Layout
03: import System.Exit
04: import XMonad.Operations
05: import qualified XMonad.StackSet as W
06: import qualified Data.Map        as M
07: import Graphics.X11.Xlib

08: -- user contributions
09: import XMonad.Prompt
10: import XMonad.Prompt.Shell
11: import XMonad.Layout.NoBorders
12: import XMonad.Util.CustomKeys

13: import Data.Bits

14: main = xmonad $ defaultConfig
15:        { terminal           = "urxvt"
16:        , normalBorderColor  = "#333333"
17:        , focusedBorderColor = "#1793d1"
18:        , defaultGaps        = [(15,0,0,0)]
19:        , layoutHook         = tiled ||| noBorders Full
20:        , keys               = customKeys delKeys insKeys
21:        }
22:        where
23:          tiled   = Tall nmaster delta ratio
24:          nmaster = 1
25:          delta   = 30/1280
26:          ratio   = 794/1280

27: delKeys :: XConfig l -> [(KeyMask, KeySym)]
28: delKeys conf@(XConfig {modMask = modMask}) =
29:     [ (modMask .|. shiftMask, xK_p) ]

30:     --, ((0, xk_XF86Sleep),               spawn "sudo pm-suspend") ]
31: insKeys :: XConfig l -> [((KeyMask, KeySym), X ())]
32: insKeys conf@(XConfig {modMask = modMask}) =
33:     [ ((modMask,               xK_p),   shellPrompt promptXPConfig)
34:     , ((modMask,               xK_Tab), windows W.focusDown)
35:     , ((modMask .|. shiftMask, xK_Tab), windows W.focusUp)
36:     , ((0, xk_XF86AudioRewind),         spawn "amixer -q set Headphone toggle")
37:     , ((0, xk_XF86AudioLowerVolume),    spawn "amixer -q set PCM 10%-")
38:     , ((0, xk_XF86AudioRaiseVolume),    spawn "amixer -q set PCM 10%+")
39:     , ((0, xk_XF86Sleep),               spawn "sudo pm-suspend") ]
40:     where xk_XF86AudioRewind      = 0x1008ff3e
41:           xk_XF86AudioLowerVolume = 0x1008ff11
42:           xk_XF86AudioRaiseVolume = 0x1008ff13
43:           xk_XF86Sleep            = 0x1008ff2f

44: promptXPConfig = defaultXPConfig
45:   { height            = 15
46:   , fgHLight          = "#3493f3"
47:   , bgHLight          = "#333333"
48:   , promptBorderWidth = 0
49:   , position          = Top
50:   }

Line 1 to 7 just import modules that you most likely need in order to configure and eventually compile xmonad (which is done by xmonad itself). As the comment in line 8 tells, line 9 to 12 import modules necessary for some user contributions. That are modules (extensions) that grants special functionality like different tiling algorithms or implementation of a prompt that makes running programs easy and much more. I suggest installing xmonad-contrib from [community].

Let's jump to line 15. main is the directive that's executed if the program is loaded (much like in C) and we want to run xmonad from there. We use xmonad's defaultConfig but we want to make some modifications that are listed in the lines 16 to 21. We set the terminal to urxvt and change the border colors. We also specify gaps that the window manager won't fill out. That area is ideal to fill with a statusbar or an x notification system like dzen2 (see below).

The layoutHook specifies the layouts we use and we can scroll through. Layouts are chained together with |||, so we specify two layouts here. First tiled and second noBorders Full. The tiled algorithm is the most well known algorithm and will split the screen in two areas. tiled is just a keyword for a more complex definition which is explained in line 23. Actually it's Tall nmaster delta ratio, though nmaster, delta and ratio are defined further in the following lines. So instead of tiled in line 19 we could have written: layoutHook = Tall 1 30/1280 794/1280. But this is too long and using where is more explaining here.

We can also cleanly modify the keys our window manager responds to using the user contributions XMonad.Util.CustomKeys (see line 12). We can apply two functions to customKeys, namely delKeys and insKeys, and modify the default key bindings that way. In delKeys we can specify the binding we want to delete from the default key bindings and with insKeys we can cleanly add some. The key bindings are a list holding tupels in the form of ((modifier, key), action). For example line 33 binds alt+p to a new action, namely spawning a prompt using the Xmonad.Prompt extension. By pressing alt+p, xmonad will execute the function shellPrompt with the given parameter promptXPConfig which is defined in line 44 where we use the defaultXPConfig and modify some values like we did in the main directive. How to use a specific extension is documented in xmonad's extension database; e.g. XMonad.Shell.Prompt.

xmonad comes with no statusbar or context menu or something like that. This functionality is passed to other programs. dzen2 is widely used as a statusbar in xmonad and you can just pass the output of a shell script (or any other script / program) to it. But you can pretty much use whatever program you like.

For example install dzen2 from [community] and run this from your .xinitrc:

echo "dzen2 is pretty cool to display stuff but capable of much more. See http://gotmor.googlepages.com/dzen for more information" | dzen2

With the correct gaps specified that will give you a statusbar doing almost nothing. But you can expand that.

I hope this gives an overview and answers most of your questions. For running xmonad it's necessary to read the user guides. You can reach them from xmonad's homepage. See the documentation section. Though it's not necessary, it's very helpful to read some haskell tutorials to get along better with xmonad's configuration file.

edit: Recent ghc breaks xmonad, see http://bbs.archlinux.org/viewtopic.php?id=42539.

Last edited by harlekin (2008-01-20 12:07:02)


Hail to the thief!

Offline

Board footer

Powered by FluxBB