]> code.delx.au - dotfiles/blob - .xmonad/xmonad.hs
xmonad: Layout tweaks
[dotfiles] / .xmonad / xmonad.hs
1 import System.IO
2 import XMonad
3 import XMonad.Hooks.DynamicLog
4 import XMonad.Hooks.ManageDocks
5 import XMonad.Hooks.Script
6 import XMonad.Layout.Grid
7 import XMonad.Layout.IM
8 import XMonad.Layout.LayoutHints
9 import XMonad.Layout.NoBorders
10 import XMonad.Layout.NoFrillsDecoration
11 import XMonad.Layout.PerWorkspace
12 import XMonad.Layout.Renamed
13 import XMonad.Layout.Tabbed
14 import XMonad.Util.Run(spawnPipe)
15 import qualified Data.Map as M
16 import qualified XMonad.StackSet as W
17
18
19 myKeys conf@(XConfig {XMonad.modMask = modm}) = M.fromList $
20 [
21 ((modm .|. shiftMask, xK_q), spawn "gnome-session-quit"),
22 ((modm .|. shiftMask, xK_h), spawn "gnome-session-quit --power-off"),
23 -- ((modm .|. shiftMask, xK_q), spawn "gnome-session-save --logout-dialog"),
24 -- ((modm .|. shiftMask, xK_h), spawn "gnome-session-save --shutdown-dialog"),
25 ((modm .|. shiftMask, xK_l), spawn "gnome-screensaver-command --lock"),
26
27 ((modm, xK_n), spawn "gnome-terminal"),
28 ((modm, xK_i), spawn "firefox"),
29
30 ((modm .|. shiftMask, xK_c ), kill),
31 ((modm, xK_space ), sendMessage NextLayout),
32 ((modm .|. shiftMask, xK_space ), setLayout $ XMonad.layoutHook conf),
33 ((modm, xK_Tab ), windows W.focusDown),
34 ((modm, xK_j ), windows W.focusDown),
35 ((modm, xK_k ), windows W.focusUp ),
36 ((modm, xK_m ), windows W.focusMaster ),
37 ((modm, xK_Return), windows W.swapMaster),
38 ((modm .|. shiftMask, xK_j ), windows W.swapDown ),
39 ((modm .|. shiftMask, xK_k ), windows W.swapUp ),
40 ((modm, xK_h ), sendMessage Shrink),
41 ((modm, xK_l ), sendMessage Expand),
42 ((modm, xK_t ), withFocused $ windows . W.sink),
43 ((modm , xK_comma ), sendMessage (IncMasterN 1)),
44 ((modm , xK_period), sendMessage (IncMasterN (-1))),
45 ((modm , xK_b ), sendMessage ToggleStruts)
46 ]
47 ++
48
49 -- mod-{w,e,r}, Switch to physical/Xinerama screens 1, 2, or 3
50 -- mod-shift-{w,e,r}, Move client to screen 1, 2, or 3
51 [((m .|. modm, key), screenWorkspace sc >>= flip whenJust (windows . f))
52 | (key, sc) <- zip [xK_o, xK_e, xK_u] [0..]
53 , (f, m) <- [(W.view, 0), (W.shift, shiftMask)]
54 ]
55 ++
56
57 -- mod-[1..9], Switch to workspace N
58 -- mod-shift-[1..9], Move client to workspace N
59 [((m .|. modm, k), windows $ f i)
60 | (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9]
61 , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]
62 ]
63
64
65
66 myManageHook = composeAll [
67 (className =? "Gnome-fallback-mount-helper" <&&> resource =? "gnome-fallback-mount-helper") --> doFloat,
68 (className =? "Firefox" <&&> resource =? "Dialog") --> doFloat,
69 manageDocks
70 ]
71
72
73 myWorkspaces = ["1", "2", "3", "4", "5", "6", "7", "8", "9"]
74
75 myLogHook xmobar = dynamicLogWithPP xmobarPP
76 {
77 ppOutput = hPutStrLn xmobar,
78 ppTitle = xmobarColor "green" "" . shorten 50
79 }
80
81
82 goldenRatio = (toRational (2/(1+sqrt(5)::Double)))
83
84 createLayout name layout =
85 renamed [Replace name] $
86 layoutHints $
87 smartBorders $
88 layout
89
90 myFullLayout = createLayout "Full" $
91 Full
92
93 myTiledLayout = createLayout "Tall" $
94 avoidStruts $
95 Tall nMaster ratioIncrement ratio where
96 nMaster = 1
97 ratioIncrement = 3/100
98 ratio = goldenRatio
99
100 myTabbedLayout = createLayout "Tab" $
101 avoidStruts $
102 simpleTabbed
103
104 myImLayout = createLayout "IM" $
105 avoidStruts $
106 noFrillsDeco shrinkText defaultTheme $
107 withIM ratio roster $ GridRatio 1
108 where
109 ratio = 1/4
110 roster = (Or (Title "Buddy List") (And (Resource "main") (ClassName "psi")))
111
112
113 myLayout =
114 (
115 onWorkspace "1" (myImLayout) $
116 onWorkspace "2" (myTabbedLayout ||| myFullLayout) $
117 (myTiledLayout ||| myTabbedLayout ||| myFullLayout)
118 )
119
120 main = do
121 xmonadDir <- getXMonadDir
122 xmobar <- spawnPipe ("xmobar " ++ xmonadDir ++ "/xmobar.hs")
123 xmonad $ defaultConfig {
124 manageHook = myManageHook <+> manageHook defaultConfig,
125 layoutHook = myLayout,
126 workspaces = myWorkspaces,
127 logHook = myLogHook xmobar,
128 keys = myKeys
129 }
130