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