]> code.delx.au - dotfiles/blob - .xmonad/xmonad.hs
xmonad: use transience for better handling of some dialogues
[dotfiles] / .xmonad / xmonad.hs
1 {-# LANGUAGE FlexibleContexts #-}
2 import System.IO
3 import XMonad
4 import XMonad.Actions.PhysicalScreens
5 import XMonad.Hooks.DynamicLog
6 import XMonad.Hooks.EwmhDesktops
7 import XMonad.Hooks.ICCCMFocus
8 import XMonad.Hooks.ManageDocks
9 import XMonad.Hooks.ManageHelpers
10 import XMonad.Hooks.SetWMName
11 import XMonad.Layout.IM
12 import XMonad.Layout.LayoutHints
13 import qualified XMonad.Layout.Magnifier as Mag
14 import XMonad.Layout.Master
15 import XMonad.Layout.NoBorders
16 import XMonad.Layout.NoFrillsDecoration
17 import XMonad.Layout.PerWorkspace
18 import XMonad.Layout.Renamed
19 import XMonad.Layout.Reflect
20 import XMonad.Layout.Tabbed
21 import XMonad.Layout.ThreeColumns
22 import XMonad.Util.Run(spawnPipe)
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 ((modm, xK_p), spawn "kupfer"),
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_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-{o,e,u}, Switch to physical/Xinerama screens 1, 2, or 3
56 -- mod-shift-{o,e,u}, Move client to screen 1, 2, or 3
57 [((m .|. modm, key), f sc)
58 | (key, sc) <- zip [xK_o, xK_e, xK_u] [0..]
59 , (f, m) <- [(viewScreen, 0), (sendToScreen, 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 isSkipTaskBar = isInProperty "_NET_WM_STATE" "_NET_WM_STATE_SKIP_TASKBAR"
76
77 myManageHook =
78 manageDocks <+>
79 composeOne [
80 transience,
81 (isSkipTaskBar -?> doFloat),
82 (isDialog -?> doFloatAt 0.1 0.1),
83 (isFullscreen -?> doFullFloat),
84 (fmap Just $ doF avoidMaster)
85 ]
86
87
88 myWorkspaces = ["1", "2", "3", "4", "5", "6", "7", "8", "9"]
89
90 myPP = xmobarPP
91 {
92 ppCurrent = xmobarColor "#A01010" "" . wrap "[" "]",
93 ppTitle = xmobarColor "#10A010" ""
94 }
95
96 myLogHook hooks = do
97 mapM (\h -> dynamicLogWithPP myPP { ppOutput = hPutStrLn h }) hooks
98 takeTopFocus -- fix for Java Swing apps
99
100 myStartupHook = do
101 setWMName "LG3D" -- fix for Java Swing apps
102
103
104 goldenRatio = (toRational (2/(1+sqrt(5)::Double)))
105
106 myTitleTheme = defaultTheme {
107 fontName = "xft:sans-serif:size=10",
108 decoHeight = 24
109 }
110
111 createLayout name layout =
112 renamed [Replace name] $
113 layoutHints $
114 smartBorders $
115 layout
116
117 myFullLayout = createLayout "Full" $
118 noBorders $
119 Full
120
121 myTiledLayout = createLayout "Tall" $
122 avoidStruts $
123 Mag.magnifierOff $
124 Tall nMaster ratioIncrement masterRatio
125 where
126 nMaster = 1
127 ratioIncrement = 3/100
128 masterRatio = goldenRatio
129
130 myTabbedLayout = createLayout "Tab" $
131 avoidStruts $
132 tabbed shrinkText myTitleTheme
133
134 myThreeColLayout = createLayout "ThreeCol" $
135 avoidStruts $
136 Mag.magnifierOff $
137 ThreeCol numMaster resizeDelta masterRatio
138 where
139 resizeDelta = 3/100
140 masterRatio = 4/10
141 numMaster = 1
142
143 myMasterTabbedLayout = createLayout "MTab" $
144 avoidStruts $
145 Mag.magnifierOff $
146 mastered resizeDelta masterRatio $
147 tabbed shrinkText myTitleTheme
148 where
149 resizeDelta = 3/100
150 masterRatio = goldenRatio
151
152 myGimpLayout = createLayout "Gimp" $
153 avoidStruts $
154 withIM (1/6) (Role "gimp-toolbox") $
155 reflectHoriz $
156 withIM (1/6) (Role "gimp-dock") $
157 reflectHoriz $
158 tabbed shrinkText myTitleTheme
159
160
161 -- This was the easiest way I found to avoid a compile error when I have
162 -- an unused layout
163 referenceAllLayoutsToAvoidErrors =
164 myFullLayout |||
165 myTiledLayout |||
166 myTabbedLayout |||
167 myThreeColLayout |||
168 myMasterTabbedLayout |||
169 myGimpLayout
170
171
172 myLayout =
173 (
174 onWorkspace "1" (myTabbedLayout ||| myMasterTabbedLayout) $
175 onWorkspace "2" (myTabbedLayout ||| myMasterTabbedLayout) $
176 onWorkspace "9" (myFullLayout ||| myMasterTabbedLayout ||| myTabbedLayout ||| myTiledLayout ||| myGimpLayout) $
177 (myMasterTabbedLayout ||| myTabbedLayout ||| myTiledLayout)
178 )
179
180 main = do
181 xmonadDir <- getXMonadDir
182 xmobars <- mapM (\x -> spawnPipe ("xmobar -x " ++ (show x) ++ " " ++ xmonadDir ++ "/xmobar.hs")) [1, 2]
183 xmonad $ ewmh defaultConfig {
184 manageHook = myManageHook,
185 layoutHook = myLayout,
186 workspaces = myWorkspaces,
187 logHook = myLogHook xmobars,
188 startupHook = myStartupHook,
189 keys = myKeys,
190 modMask = mod4Mask,
191 handleEventHook = handleEventHook defaultConfig <+> fullscreenEventHook,
192 focusFollowsMouse = False
193 }
194