]> ruderich.org/simon Gitweb - config/dotfiles.git/blob - xmonad.hs
xmonad.hs: Minor documentation update.
[config/dotfiles.git] / xmonad.hs
1 -- XMonad configuration file.
2 --
3 -- Should work fine with XMonad 0.7 and above.
4
5
6 import XMonad
7 -- Necessary for reflectVert.
8 import XMonad.Layout.Reflect
9 -- Necessary for avoidMaster.
10 import qualified XMonad.StackSet as W
11 -- Necessary for toggleLayouts.
12 import XMonad.Layout.ToggleLayouts
13 -- Necessary for smartBorders.
14 import XMonad.Layout.NoBorders
15 -- Necessary for composeOne and -?>.
16 import XMonad.Hooks.ManageHelpers
17 -- Necessary for `additionalKeys`.
18 import XMonad.Util.EZConfig
19
20
21 -- Prevent new windows from spawning in the master pane. Taken from
22 -- http://haskell.org/haskellwiki/Xmonad/Frequently_asked_questions on
23 -- 2009-06-30. Thanks. Modified to not steal focus from the master pane when a
24 -- new window is created, thanks to vav in #xmonad on Freenode (2010-04-15
25 -- 21:59).
26 avoidMaster :: W.StackSet i l a s sd -> W.StackSet i l a s sd
27 avoidMaster = W.modify' $ \c -> case c of
28     W.Stack t [] (r:rs) -> W.Stack r [] (t:rs)
29     otherwise           -> c
30
31 -- Create my custom layout.
32 --
33 -- Only use horizontal (Mirror tiled) and fullscreen layouts.
34 --
35 -- The master pane is at the top of the screen. To make sure new windows don't
36 -- spawn in the master pane avoidMaster (see below) is used. Borders are only
37 -- drawn when the screen has more then one window (smartBorders).
38 --
39 -- Thanks to jrick in #xmonad on Freenode (2009-06-29 22:19) for telling me
40 -- how to remove the vertical tiled layout.
41 --
42 -- toggleLayouts is used to allow switching to vertical tiled layout but not
43 -- using it with meta-space (see below in key bindings). Thanks to ml| in
44 -- #xmonad on Freenode (2010-06-14 09:49) how to use toggleLayouts.
45 myLayoutHook = toggleLayouts tiled $ smartBorders $ Mirror tiled ||| Full
46     where
47     -- Default tiling algorithm partitions the screen into two panes.
48     tiled   = Tall nmaster delta ratio
49     -- The default number of windows in the master pane.
50     nmaster = 1
51     -- Percent of screen to increment by when resizing panes.
52     delta   = 3/100
53     -- Default proportion of screen occupied by master pane.
54     ratio   = 1/2
55
56 -- Don't spawn new windows in the master pane (which is at the top of the
57 -- screen). Thanks to dschoepe, aavogt and especially vav in #xmonad on
58 -- Freenode (2009-06-30 02:10f).
59 --
60 -- Also some applications are spawned on specific workspaces. Thanks to
61 -- dschoepe and ivanm in #xmonad on Freenode (2009-07-12 14:50).
62 myManageHook = composeOne
63     -- Browser on "2".
64     [ className =? "Iceweasel"          -?> doF (W.shift "2")
65     -- Miscellaneous on "3".
66     , className =? "Wireshark"          -?> doF (W.shift "3")
67     , title     =? "OpenOffice.org"     -?> doF (W.shift "3") -- splash screen
68     , className =? "OpenOffice.org 2.4" -?> doF (W.shift "3")
69     , className =? "Vncviewer"          -?> doF (W.shift "3")
70     -- Wine on "4".
71     , className =? "Wine"               -?> doF (W.shift "4")
72
73     -- Don't span new windows in the master pane.
74     , return True -?> doF avoidMaster
75     -- Prevent windows which get moved to other workspaces from removing the
76     -- focus of the currently selected window. Thanks to vav in #xmonad on
77     -- Freenode (2010-04-15 21:04).
78     , return True -?> doF W.focusDown
79     ]
80
81 myKeys = [
82         -- Switch to additional layout (vertical tiled) defined by
83         -- toggleLayouts above.
84         ((mod4Mask, xK_v), sendMessage ToggleLayout)
85     ]
86     ++
87     -- When using multiple screens, switching to another workspace causes
88     -- Xmonad to pull the workspace to the current screen if it was also
89     -- displayed on another one. This is confusing for me so the following
90     -- code changes it to just switch to the screen where the workspace is
91     -- already displayed.
92     --
93     -- Thanks to the Xmonad FAQ, read on 2010-06-16 13:42
94     -- (http://www.haskell.org/haskellwiki/Xmonad/Frequently_asked_questions).
95     -- Thanks to MrElendig in #xmonad on Freenode (2010-06-17 17:16) to use
96     -- the default XMonad workspaces.
97     [((m .|. mod4Mask, k), windows $ f i)
98         | (i, k) <- zip (XMonad.workspaces defaultConfig) [xK_1 .. xK_9]
99         , (f, m) <- [(W.view, 0), (W.shift, shiftMask)]]
100
101 main = xmonad $ defaultConfig
102     -- Use Windows key as main key so it doesn't conflict with any other key
103     -- bindings.
104     { modMask = mod4Mask
105     -- Inactive borders are black - invisible on my black screen.
106     , normalBorderColor = "#000000"
107     -- Active border is dark red.
108     , focusedBorderColor = "#990000"
109     -- Use my layout and manage hooks (see above).
110     , layoutHook = myLayoutHook
111     , manageHook = myManageHook
112     -- Use unicode rxvt as my terminal.
113     , terminal = "urxvt"
114     }
115     `additionalKeys` myKeys
116
117 -- vim: nospell