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