]> code.delx.au - dotfiles/blob - .xmonad/xmonad.hs
xmonad: remove ediff rule since I now keep it in the same emacs frame
[dotfiles] / .xmonad / xmonad.hs
1 {-# LANGUAGE FlexibleContexts #-}
2 import System.IO
3 import XMonad
4 import XMonad.Actions.PhysicalScreens
5 import XMonad.Hooks.DynamicLog
6 import XMonad.Hooks.EwmhDesktops
7 import XMonad.Hooks.ICCCMFocus
8 import XMonad.Hooks.ManageDocks
9 import XMonad.Hooks.ManageHelpers
10 import XMonad.Hooks.SetWMName
11 import XMonad.Layout.IM
12 import XMonad.Layout.LayoutHints
13 import qualified XMonad.Layout.Magnifier as Mag
14 import XMonad.Layout.Master
15 import XMonad.Layout.NoBorders
16 import XMonad.Layout.NoFrillsDecoration
17 import XMonad.Layout.PerWorkspace
18 import XMonad.Layout.Renamed
19 import XMonad.Layout.Reflect
20 import XMonad.Layout.Tabbed
21 import XMonad.Layout.ThreeColumns
22 import XMonad.Util.Run(spawnPipe)
23 import qualified Data.Map as M
24 import qualified XMonad.StackSet as W
25
26
27 myKeys conf@(XConfig {XMonad.modMask = modm}) = M.fromList $
28 [
29 ((modm .|. shiftMask, xK_h), spawn "xfce4-session-logout"),
30 ((modm .|. shiftMask, xK_l), spawn "xscreensaver-command --lock"),
31 ((modm .|. shiftMask, xK_r), spawn "xmonad --restart"),
32
33 ((modm, xK_n), spawn "xfce4-terminal"),
34 ((modm, xK_i), spawn "firefox"),
35 ((modm, xK_c), spawn "emacsclient --create-frame --no-wait"),
36 ((modm, xK_p), spawn "kupfer"),
37
38 ((modm .|. shiftMask, xK_c ), kill),
39 ((modm, xK_space ), sendMessage NextLayout),
40 ((modm .|. shiftMask, xK_space ), setLayout $ XMonad.layoutHook conf),
41 ((modm, xK_j ), windows W.focusDown),
42 ((modm, xK_k ), windows W.focusUp ),
43 ((modm, xK_m ), windows W.focusMaster ),
44 ((modm, xK_Return), windows W.swapMaster),
45 ((modm .|. shiftMask, xK_j ), windows W.swapDown ),
46 ((modm .|. shiftMask, xK_k ), windows W.swapUp ),
47 ((modm, xK_h ), sendMessage Shrink),
48 ((modm, xK_l ), sendMessage Expand),
49 ((modm, xK_t ), withFocused $ windows . W.sink),
50 ((modm , xK_comma ), sendMessage (IncMasterN 1)),
51 ((modm , xK_period), sendMessage (IncMasterN (-1))),
52 ((modm , xK_b ), sendMessage ToggleStruts),
53 ((modm , xK_z ), sendMessage Mag.Toggle)
54 ]
55 ++
56
57 -- mod-{o,e,u}, Switch to physical/Xinerama screens 1, 2, or 3
58 -- mod-shift-{o,e,u}, Move client to screen 1, 2, or 3
59 [((m .|. modm, key), f sc)
60 | (key, sc) <- zip [xK_o, xK_e, xK_u] [0..]
61 , (f, m) <- [(viewScreen, 0), (sendToScreen, shiftMask)]
62 ]
63 ++
64
65 -- mod-[1..9], Switch to workspace N
66 -- mod-shift-[1..9], Move client to workspace N
67 [((m .|. modm, k), windows $ f i)
68 | (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9]
69 , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]
70 ]
71
72
73 avoidMaster = W.modify' $ \c -> case c of
74 W.Stack t [] (r:rs) -> W.Stack t [r] rs
75 otherwise -> c
76
77 isSkipTaskBar = isInProperty "_NET_WM_STATE" "_NET_WM_STATE_SKIP_TASKBAR"
78
79 myManageHook =
80 manageDocks <+>
81 composeOne [
82 transience,
83 (isSkipTaskBar -?> doFloat),
84 (isDialog -?> doFloatAt 0.1 0.1),
85 (isFullscreen -?> doFullFloat),
86 (fmap Just $ doF avoidMaster)
87 ]
88
89
90 myWorkspaces = ["1", "2", "3", "4", "5", "6", "7", "8", "9"]
91
92 myPP = xmobarPP
93 {
94 ppCurrent = xmobarColor "#A01010" "" . wrap "[" "]",
95 ppTitle = xmobarColor "#10A010" ""
96 }
97
98 myLogHook hooks = do
99 mapM (\h -> dynamicLogWithPP myPP { ppOutput = hPutStrLn h }) hooks
100 takeTopFocus -- fix for Java Swing apps
101
102 myStartupHook = do
103 setWMName "LG3D" -- fix for Java Swing apps
104 spawn "xfce4-panel --restart" -- ensure it appears on top of xmobar
105
106 goldenRatio = (toRational (2/(1+sqrt(5)::Double)))
107
108 myTitleTheme = defaultTheme {
109 fontName = "xft:sans-serif:size=10",
110 decoHeight = 24
111 }
112
113 createLayout name layout =
114 renamed [Replace name] $
115 layoutHints $
116 smartBorders $
117 layout
118
119 myFullLayout = createLayout "Full" $
120 noBorders $
121 Full
122
123 myTiledLayout = createLayout "Tall" $
124 avoidStruts $
125 Mag.magnifierOff $
126 Tall nMaster ratioIncrement masterRatio
127 where
128 nMaster = 1
129 ratioIncrement = 3/100
130 masterRatio = goldenRatio
131
132 myTabbedLayout = createLayout "Tab" $
133 avoidStruts $
134 tabbed shrinkText myTitleTheme
135
136 myThreeColLayout = createLayout "ThreeCol" $
137 avoidStruts $
138 Mag.magnifierOff $
139 ThreeCol numMaster resizeDelta masterRatio
140 where
141 resizeDelta = 3/100
142 masterRatio = 4/10
143 numMaster = 1
144
145 myMasterTabbedLayout = createLayout "MTab" $
146 avoidStruts $
147 Mag.magnifierOff $
148 mastered resizeDelta masterRatio $
149 tabbed shrinkText myTitleTheme
150 where
151 resizeDelta = 3/100
152 masterRatio = goldenRatio
153
154 myGimpLayout = createLayout "Gimp" $
155 avoidStruts $
156 withIM (1/6) (Role "gimp-toolbox") $
157 reflectHoriz $
158 withIM (1/6) (Role "gimp-dock") $
159 reflectHoriz $
160 tabbed shrinkText myTitleTheme
161
162
163 -- This was the easiest way I found to avoid a compile error when I have
164 -- an unused layout
165 referenceAllLayoutsToAvoidErrors =
166 myFullLayout |||
167 myTiledLayout |||
168 myTabbedLayout |||
169 myThreeColLayout |||
170 myMasterTabbedLayout |||
171 myGimpLayout
172
173
174 myLayout =
175 (
176 onWorkspace "1" (myTabbedLayout ||| myMasterTabbedLayout) $
177 onWorkspace "2" (myTabbedLayout ||| myMasterTabbedLayout) $
178 onWorkspace "9" (myFullLayout ||| myMasterTabbedLayout ||| myTabbedLayout ||| myTiledLayout ||| myGimpLayout) $
179 (myMasterTabbedLayout ||| myTabbedLayout ||| myTiledLayout)
180 )
181
182 main = do
183 xmonadDir <- getXMonadDir
184 xmobars <- mapM (\x -> spawnPipe ("xmobar -x " ++ (show x) ++ " " ++ xmonadDir ++ "/xmobar.hs")) [1, 2]
185 xmonad $ ewmh defaultConfig {
186 manageHook = myManageHook,
187 layoutHook = myLayout,
188 workspaces = myWorkspaces,
189 logHook = myLogHook xmobars,
190 startupHook = myStartupHook,
191 keys = myKeys,
192 modMask = mod4Mask,
193 handleEventHook = handleEventHook defaultConfig <+> fullscreenEventHook,
194 focusFollowsMouse = False
195 }
196