]> code.delx.au - dotfiles/blob - .xmonad/xmonad.hs
a16164a247545faeca22915555f65cc6e7cf5fc6
[dotfiles] / .xmonad / xmonad.hs
1 import System.IO
2 import XMonad
3 import XMonad.Hooks.DynamicLog
4 import XMonad.Hooks.ICCCMFocus
5 import XMonad.Hooks.ManageDocks
6 import XMonad.Hooks.Script
7 import XMonad.Hooks.SetWMName
8 import XMonad.Layout.IM
9 import XMonad.Layout.LayoutHints
10 import qualified XMonad.Layout.Magnifier as Mag
11 import XMonad.Hooks.ManageHelpers
12 import XMonad.Layout.NoBorders
13 import XMonad.Layout.NoFrillsDecoration
14 import XMonad.Layout.PerWorkspace
15 import XMonad.Layout.Renamed
16 import XMonad.Layout.Reflect
17 import XMonad.Layout.Tabbed
18 import XMonad.Layout.ThreeColumns
19 import XMonad.Layout.TwoPane
20 import XMonad.Util.Run(spawnPipe)
21 import qualified Data.Map as M
22 import qualified XMonad.StackSet as W
23
24
25 myKeys conf@(XConfig {XMonad.modMask = modm}) = M.fromList $
26 [
27 ((modm .|. shiftMask, xK_q), spawn "gnome-session-quit"),
28 ((modm .|. shiftMask, xK_h), spawn "gnome-session-quit --power-off"),
29 -- ((modm .|. shiftMask, xK_q), spawn "gnome-session-save --logout-dialog"),
30 -- ((modm .|. shiftMask, xK_h), spawn "gnome-session-save --shutdown-dialog"),
31 ((modm .|. shiftMask, xK_l), spawn "gnome-screensaver-command --lock"),
32
33 ((modm, xK_n), spawn "gnome-terminal"),
34 ((modm, xK_i), spawn "firefox"),
35
36 ((modm .|. shiftMask, xK_c ), kill),
37 ((modm, xK_space ), sendMessage NextLayout),
38 ((modm .|. shiftMask, xK_space ), setLayout $ XMonad.layoutHook conf),
39 ((modm, xK_Tab ), windows W.focusDown),
40 ((modm, xK_j ), windows W.focusDown),
41 ((modm, xK_k ), windows W.focusUp ),
42 ((modm, xK_m ), windows W.focusMaster ),
43 ((modm, xK_Return), windows W.swapMaster),
44 ((modm .|. shiftMask, xK_j ), windows W.swapDown ),
45 ((modm .|. shiftMask, xK_k ), windows W.swapUp ),
46 ((modm, xK_h ), sendMessage Shrink),
47 ((modm, xK_l ), sendMessage Expand),
48 ((modm, xK_t ), withFocused $ windows . W.sink),
49 ((modm , xK_comma ), sendMessage (IncMasterN 1)),
50 ((modm , xK_period), sendMessage (IncMasterN (-1))),
51 ((modm , xK_b ), sendMessage ToggleStruts),
52 ((modm , xK_z ), sendMessage Mag.Toggle)
53 ]
54 ++
55
56 -- mod-{w,e,r}, Switch to physical/Xinerama screens 1, 2, or 3
57 -- mod-shift-{w,e,r}, Move client to screen 1, 2, or 3
58 [((m .|. modm, key), screenWorkspace sc >>= flip whenJust (windows . f))
59 | (key, sc) <- zip [xK_o, xK_e, xK_u] [0..]
60 , (f, m) <- [(W.view, 0), (W.shift, shiftMask)]
61 ]
62 ++
63
64 -- mod-[1..9], Switch to workspace N
65 -- mod-shift-[1..9], Move client to workspace N
66 [((m .|. modm, k), windows $ f i)
67 | (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9]
68 , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]
69 ]
70
71
72 avoidMaster = W.modify' $ \c -> case c of
73 W.Stack t [] (r:rs) -> W.Stack t [r] rs
74 otherwise -> c
75
76 myManageHook = composeAll [
77 (className =? "Gnome-fallback-mount-helper" <&&> resource =? "gnome-fallback-mount-helper") --> doFloat,
78 (className =? "Gdu-notification-daemon" <&&> resource =? "gdu-notification-daemon") --> doFloat,
79 (className =? "Firefox" <&&> resource =? "Dialog") --> doFloat,
80 (className =? "Firefox" <&&> resource =? "Popup") --> (ask >>= doF . W.sink),
81 (className =? "Firefox" <&&> resource =? "Navigator" <&&> currentWs =? "1") --> (doShift "2"),
82 (className =? "Screenruler" <&&> resource =? "screenruler") --> doFloat,
83 (className =? "Plugin-container" <&&> resource =? "plugin-container") --> doFullFloat,
84 (className =? "Sushi-start" <&&> resource =? "sushi-start") --> (doFloatAt 0.1 0.1),
85 (fmap not isDialog --> doF avoidMaster),
86 manageDocks
87 ]
88
89
90 myWorkspaces = ["1", "2", "3", "4", "5", "6", "7", "8", "9"]
91
92 myPP = xmobarPP
93 {
94 ppTitle = xmobarColor "green" ""
95 }
96
97 myLogHook h1 =
98 dynamicLogWithPP myPP { ppOutput = hPutStrLn h1 } >>
99 takeTopFocus -- fix for Java Swing apps
100
101 myStartupHook =
102 setWMName "LG3D" -- fix for Java Swing apps
103
104
105 goldenRatio = (toRational (2/(1+sqrt(5)::Double)))
106
107 createLayout name layout =
108 renamed [Replace name] $
109 layoutHints $
110 smartBorders $
111 layout
112
113 myFullLayout = createLayout "Full" $
114 Full
115
116 myTiledLayout = createLayout "Tall" $
117 avoidStruts $
118 Mag.magnifierOff $
119 Tall nMaster ratioIncrement masterRatio
120 where
121 nMaster = 1
122 ratioIncrement = 3/100
123 masterRatio = goldenRatio
124
125 myTabbedLayout = createLayout "Tab" $
126 avoidStruts $
127 simpleTabbed
128
129 myThreeColLayout = createLayout "ThreeCol" $
130 avoidStruts $
131 Mag.magnifierOff $
132 ThreeCol numMaster resizeDelta masterRatio
133 where
134 resizeDelta = 3/100
135 masterRatio = 4/10
136 numMaster = 1
137
138 myTwoPaneLayout = createLayout "TwoPane" $
139 avoidStruts $
140 Mag.magnifierOff $
141 TwoPane resizeDelta masterRatio
142 where
143 resizeDelta = 3/100
144 masterRatio = goldenRatio
145
146 myImLayout = createLayout "IM" $
147 avoidStruts $
148 noFrillsDeco shrinkText defaultTheme $
149 withIM rosterRatio roster $
150 myTiledLayout
151 --- myThreeColLayout -- use this on wider screens
152 where
153 rosterRatio = 1/8
154 roster = (Or (Title "Buddy List") (And (Resource "main") (ClassName "psi")))
155
156 myGimpLayout = createLayout "Gimp" $
157 avoidStruts $
158 withIM (1/6) (Role "gimp-toolbox") $
159 reflectHoriz $
160 withIM (1/6) (Role "gimp-dock") $
161 reflectHoriz $
162 simpleTabbed
163
164
165 -- This was the easiest way I found to avoid a compile error when I have
166 -- an unused layout
167 referenceAllLayoutsToAvoidErrors =
168 myFullLayout |||
169 myTiledLayout |||
170 myTabbedLayout |||
171 myThreeColLayout |||
172 myTwoPaneLayout |||
173 myImLayout |||
174 myGimpLayout
175
176
177 myLayout =
178 (
179 onWorkspace "1" (myImLayout) $
180 onWorkspace "2" (myTabbedLayout ||| myFullLayout) $
181 onWorkspace "7" (myTiledLayout ||| myTabbedLayout ||| myGimpLayout) $
182 (myTiledLayout ||| myTabbedLayout)
183 )
184
185 main = do
186 xmonadDir <- getXMonadDir
187 xmobar <- spawnPipe ("xmobar " ++ xmonadDir ++ "/xmobar.hs")
188 xmonad $ defaultConfig {
189 manageHook = myManageHook <+> manageHook defaultConfig,
190 layoutHook = myLayout,
191 workspaces = myWorkspaces,
192 logHook = myLogHook xmobar,
193 startupHook = myStartupHook,
194 keys = myKeys
195 }
196