]> code.delx.au - dotfiles/blob - .xmonad/xmonad.hs
xmonad: Tile Firefox network inspection window
[dotfiles] / .xmonad / xmonad.hs
1 import System.IO
2 import XMonad
3 import XMonad.Hooks.DynamicLog
4 import XMonad.Hooks.EwmhDesktops
5 import XMonad.Hooks.ICCCMFocus
6 import XMonad.Hooks.ManageDocks
7 import XMonad.Hooks.Script
8 import XMonad.Hooks.SetWMName
9 import XMonad.Layout.IM
10 import XMonad.Layout.LayoutHints
11 import qualified XMonad.Layout.Magnifier as Mag
12 import XMonad.Hooks.ManageHelpers
13 import XMonad.Layout.NoBorders
14 import XMonad.Layout.NoFrillsDecoration
15 import XMonad.Layout.PerWorkspace
16 import XMonad.Layout.Renamed
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
73 myManageHook = composeAll [
74 (className =? "Gnome-fallback-mount-helper" <&&> resource =? "gnome-fallback-mount-helper") --> doFloat,
75 (className =? "Gdu-notification-daemon" <&&> resource =? "gdu-notification-daemon") --> doFloat,
76 (className =? "Firefox" <&&> resource =? "Dialog") --> doFloat,
77 (className =? "Firefox" <&&> resource =? "Popup") --> (ask >>= doF . W.sink),
78 (className =? "Screenruler" <&&> resource =? "screenruler") --> doFloat,
79 (className =? "Plugin-container" <&&> resource =? "plugin-container") --> doFullFloat,
80 manageDocks
81 ]
82
83
84 myWorkspaces = ["1", "2", "3", "4", "5", "6", "7", "8", "9"]
85
86 myPP = xmobarPP
87 {
88 ppTitle = xmobarColor "green" ""
89 }
90
91 myLogHook h1 =
92 dynamicLogWithPP myPP { ppOutput = hPutStrLn h1 } >>
93 takeTopFocus -- fix for Java Swing apps
94
95 myStartupHook =
96 setWMName "LG3D" -- fix for Java Swing apps
97
98
99 goldenRatio = (toRational (2/(1+sqrt(5)::Double)))
100
101 createLayout name layout =
102 renamed [Replace name] $
103 layoutHints $
104 smartBorders $
105 layout
106
107 myFullLayout = createLayout "Full" $
108 Full
109
110 myTiledLayout = createLayout "Tall" $
111 avoidStruts $
112 Mag.magnifierOff $
113 Tall nMaster ratioIncrement masterRatio
114 where
115 nMaster = 1
116 ratioIncrement = 3/100
117 masterRatio = goldenRatio
118
119 myTabbedLayout = createLayout "Tab" $
120 avoidStruts $
121 simpleTabbed
122
123 myThreeColLayout = createLayout "ThreeCol" $
124 avoidStruts $
125 Mag.magnifierOff $
126 ThreeCol numMaster resizeDelta masterRatio
127 where
128 resizeDelta = 3/100
129 masterRatio = 4/10
130 numMaster = 1
131
132 myTwoPaneLayout = createLayout "TwoPane" $
133 avoidStruts $
134 Mag.magnifierOff $
135 TwoPane resizeDelta masterRatio
136 where
137 resizeDelta = 3/100
138 masterRatio = goldenRatio
139
140 myImLayout = createLayout "IM" $
141 avoidStruts $
142 noFrillsDeco shrinkText defaultTheme $
143 withIM rosterRatio roster $
144 myTiledLayout
145 --- myThreeColLayout -- use this on wider screens
146 where
147 rosterRatio = 1/8
148 roster = (Or (Title "Buddy List") (And (Resource "main") (ClassName "psi")))
149
150 -- This was the easiest way I found to avoid a compile error when I have
151 -- an unused layout
152 referenceAllLayoutsToAvoidErrors =
153 myFullLayout |||
154 myTiledLayout |||
155 myTabbedLayout |||
156 myThreeColLayout |||
157 myTwoPaneLayout |||
158 myImLayout
159
160
161 myLayout =
162 (
163 onWorkspace "1" (myImLayout) $
164 onWorkspace "2" (myTabbedLayout ||| myFullLayout) $
165 (myTiledLayout ||| myTabbedLayout)
166 )
167
168 main = do
169 xmonadDir <- getXMonadDir
170 xmobar <- spawnPipe ("xmobar " ++ xmonadDir ++ "/xmobar.hs")
171 xmonad $ ewmh defaultConfig {
172 manageHook = myManageHook <+> manageHook defaultConfig,
173 layoutHook = myLayout,
174 workspaces = myWorkspaces,
175 logHook = myLogHook xmobar,
176 startupHook = myStartupHook,
177 keys = myKeys
178 }
179