]> ruderich.org/simon Gitweb - config/dotfiles.git/blob - xmonad.hs
xmonad.hs: Don't automatically move workspaces in multi screen setup.
[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     [ className =? "Iceweasel" -?> doF (W.shift "2")
64     , className =? "Wireshark" -?> doF (W.shift "3")
65
66     -- Don't span new windows in the master pane.
67     , return True -?> doF avoidMaster
68     -- Prevent windows which get moved to other workspaces from removing the
69     -- focus of the currently selected window. Thanks to vav in #xmonad on
70     -- Freenode (2010-04-15 21:04).
71     , return True -?> doF W.focusDown
72     ]
73
74 -- My workspaces, same as default ones. Used below in myKeys.
75 myWorkspaces = ["1", "2", "3", "4", "5", "6", "7", "8", "9"]
76
77 myKeys = [
78         -- Switch to additional layout (vertical tiled) defined by
79         -- toggleLayouts above.
80         ((mod4Mask, xK_v), sendMessage ToggleLayout)
81     ]
82     ++
83     -- When using multiple screens, switching to another workspace causes
84     -- Xmonad to pull the workspace to the current screen if it was also
85     -- displayed on another one. This is confusing for me so the following
86     -- code changes it to just switch to the screen where the workspace is
87     -- already displayed.
88     --
89     -- Thanks to the Xmonad FAQ, read on 2010-06-16 13:42
90     -- (http://www.haskell.org/haskellwiki/Xmonad/Frequently_asked_questions).
91     [((m .|. mod4Mask, k), windows $ f i)
92         | (i, k) <- zip myWorkspaces [xK_1 .. xK_9]
93         , (f, m) <- [(W.view, 0), (W.shift, shiftMask)]]
94
95 main = xmonad $ defaultConfig
96     -- Use Windows key as main key so it doesn't conflict with any other key
97     -- bindings.
98     { modMask = mod4Mask
99     -- Inactive borders are black - invisible on my black screen.
100     , normalBorderColor = "#000000"
101     -- Active border is dark red.
102     , focusedBorderColor = "#990000"
103     -- Use my layout and manage hooks (see above).
104     , layoutHook = myLayoutHook
105     , manageHook = myManageHook
106     -- Use unicode rxvt as my terminal.
107     , terminal = "urxvt"
108     }
109     `additionalKeys` myKeys
110
111 -- vim: nospell