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)
58 ||| named "Full" (smartBorders Full)
59 ||| named "Vertical" (smartBorders tiled)
61 -- Default tiling algorithm partitions the screen into two panes.
62 tiled = Tall nmaster delta ratio
63 -- The default number of windows in the master pane.
65 -- Percent of screen to increment by when resizing panes.
67 -- Default proportion of screen occupied by master pane.
70 -- Don't spawn new windows in the master pane (which is at the top of the
71 -- screen). Thanks to dschoepe, aavogt and especially vav in #xmonad on
72 -- Freenode (2009-06-30 02:10f CEST).
74 -- Also some applications are spawned on specific workspaces. Thanks to
75 -- dschoepe and ivanm in #xmonad on Freenode (2009-07-12 14:50 CEST).
76 myManageHook = composeOne
78 [ className =? "Iceweasel" -?> doF (W.shift "2")
79 -- Miscellaneous on "3".
80 , className =? "Wireshark" -?> doF (W.shift "3")
81 , title =? "OpenOffice.org" -?> doF (W.shift "3") -- splash screen
82 , className =? "OpenOffice.org 2.4" -?> doF (W.shift "3")
83 , className =? "Vncviewer" -?> doF (W.shift "3")
85 , className =? "Wine" -?> doF (W.shift "4")
87 -- Don't spawn new windows in the master pane.
88 , return True -?> doF avoidMaster
89 -- Prevent windows which get moved to other workspaces from removing the
90 -- focus of the currently selected window. Thanks to vav in #xmonad on
91 -- Freenode (2010-04-15 21:04 CEST).
92 , return True -?> doF W.focusDown
95 -- Switch to next layout, but skip all layouts not in layouts argument. This
96 -- allows switching to some layouts with mappings but excluding them from
97 -- meta-space (which gets mapped to this function). Thanks to aavogt in
98 -- #xmonad on Freenode for this function (2011-06-13 12:45 CEST) and
99 -- rootzlevel in #xmonad on Freenode for fixes (2011-06-13 15:20 CEST),
100 -- modified to take list of layouts to switch to, not layouts to exclude.
101 nextLayoutIncluding :: [String] -> X ()
102 nextLayoutIncluding layouts = do
103 cws <- gets (W.workspace . W.current . windowset)
104 sendMessageWithNoRefresh NextLayout cws
105 nextLayoutIncluding' layouts
107 nextLayoutIncluding' :: [String] -> X ()
108 nextLayoutIncluding' layouts = do
109 cws <- gets (W.workspace . W.current . windowset)
110 if not $ (description $ W.layout cws) `elem` layouts
111 -- Skip over excluded layouts.
113 sendMessageWithNoRefresh NextLayout cws
114 nextLayoutIncluding' layouts
115 -- Found allowed layout, show it.
119 -- Switch to next layout, but only use the listed layouts.
120 ((mod4Mask, xK_space), nextLayoutIncluding ["Default", "Full"])
121 -- Switch to vertical tiled layout.
122 , ((mod4Mask, xK_v), sendMessage $ JumpToLayout "Vertical")
124 -- Switch to last active workspace, thanks to moljac024 in #xmonad on
125 -- Freenode (2010-12-18 14:45 CET).
126 , ((mod4Mask, xK_f), toggleWS)
129 -- When using multiple screens, switching to another workspace causes
130 -- Xmonad to pull the workspace to the current screen if it was also
131 -- displayed on another one. This is confusing for me so the following
132 -- code changes it to just switch to the screen where the workspace is
133 -- already displayed.
135 -- Thanks to the Xmonad FAQ, read on 2010-06-16 13:42 CEST
136 -- (http://www.haskell.org/haskellwiki/Xmonad/Frequently_asked_questions).
137 -- Thanks to MrElendig in #xmonad on Freenode (2010-06-17 17:16 CEST) to
138 -- use the default XMonad workspaces.
139 [((m .|. mod4Mask, k), windows $ f i)
140 | (i, k) <- zip (XMonad.workspaces defaultConfig) [xK_1 .. xK_9]
141 , (f, m) <- [(W.view, 0), (W.shift, shiftMask)]]
143 main = xmonad $ defaultConfig
144 -- Use Windows key as main key as it doesn't conflict with any other key
147 -- Inactive borders are black - invisible on my black screen.
148 , normalBorderColor = "#000000"
149 -- Active borders are dark red.
150 , focusedBorderColor = "#990000"
151 -- Use my layout and manage hooks (see above).
152 , layoutHook = myLayoutHook
153 , manageHook = myManageHook
154 -- Use unicode rxvt as my terminal.
156 -- Necessary for Java so it recognizes XMonad as tiling window manager.
157 , startupHook = setWMName "LG3D"
159 `additionalKeys` myKeys