]> code.delx.au - dotfiles/blob - .xmonad/xmonad.hs
xmonad: added new floating window special case
[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.ManageHelpers
8 import XMonad.Hooks.Script
9 import XMonad.Hooks.SetWMName
10 import XMonad.Layout.IM
11 import XMonad.Layout.LayoutHints
12 import qualified XMonad.Layout.Magnifier as Mag
13 import XMonad.Layout.Master
14 import XMonad.Layout.NoBorders
15 import XMonad.Layout.NoFrillsDecoration
16 import XMonad.Layout.PerWorkspace
17 import XMonad.Layout.Renamed
18 import XMonad.Layout.Reflect
19 import XMonad.Layout.Tabbed
20 import XMonad.Layout.ThreeColumns
21 import XMonad.Util.Run(spawnPipe)
22 import XMonad.Util.WindowProperties(getProp32s)
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
32 ((modm, xK_n), spawn "xfce4-terminal"),
33 ((modm, xK_i), spawn "firefox"),
34
35 ((modm .|. shiftMask, xK_c ), kill),
36 ((modm, xK_space ), sendMessage NextLayout),
37 ((modm .|. shiftMask, xK_space ), setLayout $ XMonad.layoutHook conf),
38 ((modm, xK_Tab ), windows W.focusDown),
39 ((modm, xK_j ), windows W.focusDown),
40 ((modm, xK_k ), windows W.focusUp ),
41 ((modm, xK_m ), windows W.focusMaster ),
42 ((modm, xK_Return), windows W.swapMaster),
43 ((modm .|. shiftMask, xK_j ), windows W.swapDown ),
44 ((modm .|. shiftMask, xK_k ), windows W.swapUp ),
45 ((modm, xK_h ), sendMessage Shrink),
46 ((modm, xK_l ), sendMessage Expand),
47 ((modm, xK_t ), withFocused $ windows . W.sink),
48 ((modm , xK_comma ), sendMessage (IncMasterN 1)),
49 ((modm , xK_period), sendMessage (IncMasterN (-1))),
50 ((modm , xK_b ), sendMessage ToggleStruts),
51 ((modm , xK_z ), sendMessage Mag.Toggle)
52 ]
53 ++
54
55 -- mod-{w,e,r}, Switch to physical/Xinerama screens 1, 2, or 3
56 -- mod-shift-{w,e,r}, Move client to screen 1, 2, or 3
57 [((m .|. modm, key), screenWorkspace sc >>= flip whenJust (windows . f))
58 | (key, sc) <- zip [xK_o, xK_e, xK_u] [0..]
59 , (f, m) <- [(W.view, 0), (W.shift, shiftMask)]
60 ]
61 ++
62
63 -- mod-[1..9], Switch to workspace N
64 -- mod-shift-[1..9], Move client to workspace N
65 [((m .|. modm, k), windows $ f i)
66 | (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9]
67 , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]
68 ]
69
70
71 avoidMaster = W.modify' $ \c -> case c of
72 W.Stack t [] (r:rs) -> W.Stack t [r] rs
73 otherwise -> c
74
75 isTransient = ask >>= \w -> liftX $ do
76 r <- getProp32s "WM_TRANSIENT_FOR" w
77 return $ case r of
78 Just [_] -> True
79 _ -> False
80
81 isSkipTaskBar = isInProperty "_NET_WM_STATE" "_NET_WM_STATE_SKIP_TASKBAR"
82
83
84 myManageHook =
85 manageDocks <+>
86 composeOne [
87 (className =? "Firefox" <&&> resource =? "Popup") -?> (ask >>= doF . W.sink),
88 (className =? "Firefox" <&&> resource =? "Navigator" <&&> currentWs =? "1") -?> (doShift "2"),
89 (className =? "Kupfer.py" <&&> resource =? "kupfer.py") -?> doFloat,
90 (className =? "Xfce4-appfinder" <&&> resource =? "xfce4-appfinder") -?> doFloatAt 0.1 0.1,
91 (isSkipTaskBar -?> doFloat),
92 (isDialog -?> doFloatAt 0.1 0.1),
93 (isTransient -?> doFloatAt 0.1 0.1),
94 (isFullscreen -?> doFullFloat),
95 (fmap Just $ doF avoidMaster)
96 ]
97
98
99 myWorkspaces = ["1", "2", "3", "4", "5", "6", "7", "8", "9"]
100
101 myPP = xmobarPP
102 {
103 ppCurrent = xmobarColor "#A01010" "" . wrap "[" "]",
104 ppTitle = xmobarColor "#10A010" ""
105 }
106
107 myLogHook h1 h2 =
108 dynamicLogWithPP myPP { ppOutput = hPutStrLn h1 } >>
109 dynamicLogWithPP myPP { ppOutput = hPutStrLn h2 } >>
110 takeTopFocus -- fix for Java Swing apps
111
112 myStartupHook =
113 setWMName "LG3D" -- fix for Java Swing apps
114
115
116 goldenRatio = (toRational (2/(1+sqrt(5)::Double)))
117
118 myTitleTheme = defaultTheme {
119 fontName = "xft:sans-serif:size=10",
120 decoHeight = 22
121 }
122
123 createLayout name layout =
124 renamed [Replace name] $
125 layoutHints $
126 smartBorders $
127 layout
128
129 myFullLayout = createLayout "Full" $
130 Full
131
132 myTiledLayout = createLayout "Tall" $
133 avoidStruts $
134 Mag.magnifierOff $
135 Tall nMaster ratioIncrement masterRatio
136 where
137 nMaster = 1
138 ratioIncrement = 3/100
139 masterRatio = goldenRatio
140
141 myTabbedLayout = createLayout "Tab" $
142 avoidStruts $
143 tabbed shrinkText myTitleTheme
144
145 myThreeColLayout = createLayout "ThreeCol" $
146 avoidStruts $
147 Mag.magnifierOff $
148 ThreeCol numMaster resizeDelta masterRatio
149 where
150 resizeDelta = 3/100
151 masterRatio = 4/10
152 numMaster = 1
153
154 myMasterTabbedLayout = createLayout "MTab" $
155 avoidStruts $
156 Mag.magnifierOff $
157 mastered resizeDelta masterRatio $
158 tabbed shrinkText myTitleTheme
159 where
160 resizeDelta = 3/100
161 masterRatio = goldenRatio
162
163 myImLayout = createLayout "IM" $
164 avoidStruts $
165 noFrillsDeco shrinkText myTitleTheme $
166 withIM rosterRatio roster $
167 myTiledLayout
168 --- myThreeColLayout -- use this on wider screens
169 where
170 rosterRatio = 1/8
171 roster = (Or (Title "Buddy List") (And (Resource "main") (ClassName "psi")))
172
173 myGimpLayout = createLayout "Gimp" $
174 avoidStruts $
175 withIM (1/6) (Role "gimp-toolbox") $
176 reflectHoriz $
177 withIM (1/6) (Role "gimp-dock") $
178 reflectHoriz $
179 tabbed shrinkText myTitleTheme
180
181
182 -- This was the easiest way I found to avoid a compile error when I have
183 -- an unused layout
184 referenceAllLayoutsToAvoidErrors =
185 myFullLayout |||
186 myTiledLayout |||
187 myTabbedLayout |||
188 myThreeColLayout |||
189 myMasterTabbedLayout |||
190 myImLayout |||
191 myGimpLayout
192
193
194 myLayout =
195 (
196 onWorkspace "1" (myImLayout) $
197 onWorkspace "2" (myTabbedLayout ||| myMasterTabbedLayout) $
198 onWorkspace "9" (myMasterTabbedLayout ||| myTabbedLayout ||| myTiledLayout ||| myFullLayout ||| myGimpLayout) $
199 (myMasterTabbedLayout ||| myTabbedLayout ||| myTiledLayout)
200 )
201
202 main = do
203 xmonadDir <- getXMonadDir
204 xmobar <- spawnPipe ("xmobar " ++ xmonadDir ++ "/xmobar.hs")
205 xmobar2 <- spawnPipe ("xmobar -x 1 " ++ xmonadDir ++ "/xmobar.hs")
206 xmonad $ ewmh defaultConfig {
207 manageHook = myManageHook,
208 layoutHook = myLayout,
209 workspaces = myWorkspaces,
210 logHook = myLogHook xmobar xmobar2,
211 startupHook = myStartupHook,
212 keys = myKeys
213 }
214