1 -- XMonad configuration file.
3 -- Should work fine with XMonad 0.7 and above.
6 -- "hiding" necessary for LayoutCombinators.
7 import XMonad hiding ( (|||) )
8 -- Necessary for reflectVert.
9 import XMonad.Layout.Reflect
10 -- Necessary for avoidMaster.
11 import qualified XMonad.StackSet as W
12 -- Necessary for toggleLayouts.
13 import XMonad.Layout.ToggleLayouts
14 -- Necessary for smartBorders.
15 import XMonad.Layout.NoBorders
16 -- Necessary for composeOne and -?>.
17 import XMonad.Hooks.ManageHelpers
18 -- Necessary for `additionalKeys`.
19 import XMonad.Util.EZConfig
20 -- Necessary for setWMName.
21 import XMonad.Hooks.SetWMName
22 -- Necessary for toggleWS.
23 import XMonad.Actions.CycleWS
24 -- Necessary for named.
25 import XMonad.Layout.Named
26 -- Necessary for JumpToLayout.
27 import XMonad.Layout.LayoutCombinators
30 -- Prevent new windows from spawning in the master pane. Taken from
31 -- http://haskell.org/haskellwiki/Xmonad/Frequently_asked_questions on
32 -- 2009-06-30. Thanks. Modified to not steal focus from the master pane when a
33 -- new window is created, thanks to vav in #xmonad on Freenode (2010-04-15
35 avoidMaster :: W.StackSet i l a s sd -> W.StackSet i l a s sd
36 avoidMaster = W.modify' $ \c -> case c of
37 W.Stack t [] (r:rs) -> W.Stack r [] (t:rs)
40 -- Create my custom layout.
42 -- Only use horizontal (Mirror tiled) and fullscreen layouts, but allow
43 -- switching to other layouts with bindings.
45 -- The master pane is at the top of the screen. To make sure new windows don't
46 -- spawn in the master pane avoidMaster (see below) is used. Borders are only
47 -- drawn when the screen has more then one window (smartBorders).
49 -- Thanks to jrick in #xmonad on Freenode (2009-06-29 22:19 CEST) for telling
50 -- me how to remove the vertical tiled layout.
52 -- JumpToLayout (from LayoutCombinators) is used to jump to specific layouts,
53 -- thanks to aavogt in #xmonad on Freenode (2011-06-12 22:13 CEST).
55 -- named is used to name layouts which allows switching to a specific layout
56 -- (see below), thanks to vav in #xmonad on Freenode (2011-06-12 22:28 CEST).
57 myLayoutHook = named "Default" (smartBorders $ Mirror tiled) ||| Full ||| named "Vertical" tiled
59 -- Default tiling algorithm partitions the screen into two panes.
60 tiled = Tall nmaster delta ratio
61 -- The default number of windows in the master pane.
63 -- Percent of screen to increment by when resizing panes.
65 -- Default proportion of screen occupied by master pane.
68 -- Don't spawn new windows in the master pane (which is at the top of the
69 -- screen). Thanks to dschoepe, aavogt and especially vav in #xmonad on
70 -- Freenode (2009-06-30 02:10f CEST).
72 -- Also some applications are spawned on specific workspaces. Thanks to
73 -- dschoepe and ivanm in #xmonad on Freenode (2009-07-12 14:50 CEST).
74 myManageHook = composeOne
76 [ className =? "Iceweasel" -?> doF (W.shift "2")
77 -- Miscellaneous on "3".
78 , className =? "Wireshark" -?> doF (W.shift "3")
79 , title =? "OpenOffice.org" -?> doF (W.shift "3") -- splash screen
80 , className =? "OpenOffice.org 2.4" -?> doF (W.shift "3")
81 , className =? "Vncviewer" -?> doF (W.shift "3")
83 , className =? "Wine" -?> doF (W.shift "4")
85 -- Don't spawn new windows in the master pane.
86 , return True -?> doF avoidMaster
87 -- Prevent windows which get moved to other workspaces from removing the
88 -- focus of the currently selected window. Thanks to vav in #xmonad on
89 -- Freenode (2010-04-15 21:04 CEST).
90 , return True -?> doF W.focusDown
93 -- Switch to next layout, but skip all layouts not in layouts argument. This
94 -- allows switching to some layouts with mappings but excluding them from
95 -- meta-space (which gets mapped to this function). Thanks to aavogt in
96 -- #xmonad on Freenode for this function (2011-06-13 12:45 CEST) and
97 -- rootzlevel in #xmonad on Freenode for fixes (2011-06-13 15:20 CEST),
98 -- modified to take list of layouts to switch to, not layouts to exclude.
99 nextLayoutIncluding :: [String] -> X ()
100 nextLayoutIncluding layouts = do
101 cws <- gets (W.workspace . W.current . windowset)
102 sendMessageWithNoRefresh NextLayout cws
103 nextLayoutIncluding' layouts
105 nextLayoutIncluding' :: [String] -> X ()
106 nextLayoutIncluding' layouts = do
107 cws <- gets (W.workspace . W.current . windowset)
108 if not $ (description $ W.layout cws) `elem` layouts
109 -- Skip over excluded layouts.
111 sendMessageWithNoRefresh NextLayout cws
112 nextLayoutIncluding' layouts
113 -- Found allowed layout, show it.
117 -- Switch to next layout, but only use the listed layouts.
118 ((mod4Mask, xK_space), nextLayoutIncluding ["Default", "Full"])
119 -- Switch to vertical tiled layout.
120 , ((mod4Mask, xK_v), sendMessage $ JumpToLayout "Vertical")
122 -- Switch to last active workspace, thanks to moljac024 in #xmonad on
123 -- Freenode (2010-12-18 14:45 CET).
124 , ((mod4Mask, xK_f), toggleWS)
127 -- When using multiple screens, switching to another workspace causes
128 -- Xmonad to pull the workspace to the current screen if it was also
129 -- displayed on another one. This is confusing for me so the following
130 -- code changes it to just switch to the screen where the workspace is
131 -- already displayed.
133 -- Thanks to the Xmonad FAQ, read on 2010-06-16 13:42 CEST
134 -- (http://www.haskell.org/haskellwiki/Xmonad/Frequently_asked_questions).
135 -- Thanks to MrElendig in #xmonad on Freenode (2010-06-17 17:16 CEST) to
136 -- use the default XMonad workspaces.
137 [((m .|. mod4Mask, k), windows $ f i)
138 | (i, k) <- zip (XMonad.workspaces defaultConfig) [xK_1 .. xK_9]
139 , (f, m) <- [(W.view, 0), (W.shift, shiftMask)]]
141 main = xmonad $ defaultConfig
142 -- Use Windows key as main key as it doesn't conflict with any other key
145 -- Inactive borders are black - invisible on my black screen.
146 , normalBorderColor = "#000000"
147 -- Active borders are dark red.
148 , focusedBorderColor = "#990000"
149 -- Use my layout and manage hooks (see above).
150 , layoutHook = myLayoutHook
151 , manageHook = myManageHook
152 -- Use unicode rxvt as my terminal.
154 -- Necessary for Java so it recognizes XMonad as tiling window manager.
155 , startupHook = setWMName "LG3D"
157 `additionalKeys` myKeys