]> code.delx.au - dotfiles/blob - .xmonad/xmonad.hs
2798d9d3ab26c6e4e12c6852070770709c35c6c7
[dotfiles] / .xmonad / xmonad.hs
1 {-# LANGUAGE FlexibleContexts #-}
2 import System.IO
3 import XMonad
4 import XMonad.Actions.CycleRecentWS
5 import XMonad.Actions.PhysicalScreens
6 import XMonad.Config.Desktop
7 import XMonad.Hooks.DynamicLog
8 import XMonad.Hooks.EwmhDesktops
9 import XMonad.Hooks.ICCCMFocus
10 import XMonad.Hooks.ManageDocks
11 import XMonad.Hooks.ManageHelpers
12 import XMonad.Hooks.SetWMName
13 import XMonad.Layout.IM
14 import XMonad.Layout.LayoutHints
15 import qualified XMonad.Layout.Magnifier as Mag
16 import XMonad.Layout.Master
17 import XMonad.Layout.NoBorders
18 import XMonad.Layout.NoFrillsDecoration
19 import XMonad.Layout.PerWorkspace
20 import XMonad.Layout.Renamed
21 import XMonad.Layout.Reflect
22 import XMonad.Layout.Tabbed
23 import XMonad.Util.Run(spawnPipe)
24 import qualified Data.Map as M
25 import qualified XMonad.StackSet as W
26
27
28 myKeys conf@(XConfig {XMonad.modMask = modm}) = M.fromList $
29 [
30 ((modm .|. shiftMask, xK_h), spawn "xfce4-session-logout"),
31 ((modm .|. shiftMask, xK_l), spawn "xscreensaver-command --lock"),
32 ((modm .|. shiftMask, xK_r), spawn "xmonad --restart"),
33
34 ((modm, xK_n), spawn "xfce4-terminal"),
35 ((modm, xK_i), spawn "firefox"),
36 ((modm .|. shiftMask, xK_i), spawn "firefox --private-window"),
37 ((modm, xK_c), spawn "emacsclient --create-frame --no-wait"),
38 ((modm, xK_p), spawn "kupfer"),
39
40 ((modm .|. shiftMask, xK_c ), kill),
41 ((modm, xK_space ), sendMessage NextLayout),
42 ((modm .|. shiftMask, xK_space ), setLayout $ XMonad.layoutHook conf),
43 ((modm, xK_j ), windows W.focusDown),
44 ((modm, xK_k ), windows W.focusUp ),
45 ((modm, xK_m ), windows W.focusMaster ),
46 ((modm, xK_Return), windows W.swapMaster),
47 ((modm .|. shiftMask, xK_j ), windows W.swapDown ),
48 ((modm .|. shiftMask, xK_k ), windows W.swapUp ),
49 ((modm, xK_h ), sendMessage Shrink),
50 ((modm, xK_l ), sendMessage Expand),
51 ((modm, xK_t ), withFocused $ windows . W.sink),
52 ((modm , xK_comma ), sendMessage (IncMasterN 1)),
53 ((modm , xK_period), sendMessage (IncMasterN (-1))),
54 ((modm , xK_b ), sendMessage ToggleStruts),
55 ((modm , xK_z ), sendMessage Mag.Toggle),
56 ((modm , xK_a), cycleRecentWorkspaceOnSingleScreen [xK_Super_L] xK_a xK_a)
57 ]
58 ++
59
60 -- mod-{o,e,u}, Switch to physical/Xinerama screens 1, 2, or 3
61 -- mod-shift-{o,e,u}, Move client to screen 1, 2, or 3
62 [((m .|. modm, key), screenWorkspace sc >>= flip whenJust (windows . f))
63 | (key, sc) <- zip [xK_o, xK_e, xK_u] [0..]
64 , (f, m) <- [(W.view, 0), (W.shift, shiftMask)]]
65 ++
66
67 -- mod-[1..9], Switch to workspace N
68 -- mod-shift-[1..9], Move client to workspace N
69 [((m .|. modm, k), windows $ f i)
70 | (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9]
71 , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]
72 ]
73
74 cycleRecentWorkspaceOnSingleScreen = cycleWindowSets options
75 where
76 options w = map (W.view `flip` w) (recentTags w)
77 recentTags w = map W.tag $ W.hidden w ++ [W.workspace (W.current w)]
78
79 avoidMaster = W.modify' $ \c -> case c of
80 W.Stack t [] (r:rs) -> W.Stack t [r] rs
81 otherwise -> c
82
83 isSkipTaskBar = isInProperty "_NET_WM_STATE" "_NET_WM_STATE_SKIP_TASKBAR"
84
85 myManageHook =
86 manageDocks <+>
87 composeOne [
88 transience,
89 (isSkipTaskBar -?> doFloat),
90 (isDialog -?> doFloatAt 0.1 0.1),
91 (isFullscreen -?> doFullFloat),
92 (fmap Just $ doF avoidMaster)
93 ]
94
95
96 myWorkspaces = ["1", "2", "3", "4", "5", "6", "7", "8", "9"]
97
98 myPP = xmobarPP
99 {
100 ppCurrent = xmobarColor "#A01010" "" . wrap "[" "]",
101 ppTitle = xmobarColor "#10A010" ""
102 }
103
104 myLogHook hooks = do
105 mapM (\h -> dynamicLogWithPP myPP { ppOutput = hPutStrLn h }) hooks
106 takeTopFocus -- fix for Java Swing apps
107
108 myStartupHook = do
109 setWMName "LG3D" -- fix for Java Swing apps
110 spawn "xfce4-panel --restart" -- ensure it appears on top of xmobar
111
112 goldenRatio = (toRational (2/(1+sqrt(5)::Double)))
113
114 myTitleTheme = defaultTheme {
115 fontName = "xft:sans-serif:size=10",
116 decoHeight = 24
117 }
118
119 createLayout name layout =
120 renamed [Replace name] $
121 layoutHints $
122 smartBorders $
123 layout
124
125 myFullLayout = createLayout "Full" $
126 noBorders $
127 Full
128
129 myTiledLayout = createLayout "Tall" $
130 avoidStruts $
131 Mag.magnifierOff $
132 Tall nMaster ratioIncrement masterRatio
133 where
134 nMaster = 1
135 ratioIncrement = 3/100
136 masterRatio = goldenRatio
137
138 myTabbedLayout = createLayout "Tab" $
139 avoidStruts $
140 tabbed shrinkText myTitleTheme
141
142 myMasterTabbedLayout = createLayout "MTab" $
143 avoidStruts $
144 Mag.magnifierOff $
145 mastered resizeDelta masterRatio $
146 tabbed shrinkText myTitleTheme
147 where
148 resizeDelta = 3/100
149 masterRatio = goldenRatio
150
151 myGimpLayout = createLayout "Gimp" $
152 avoidStruts $
153 withIM (1/6) (Role "gimp-toolbox") $
154 reflectHoriz $
155 withIM (1/6) (Role "gimp-dock") $
156 reflectHoriz $
157 tabbed shrinkText myTitleTheme
158
159 myLayout =
160 (
161 onWorkspace "9" (myTabbedLayout ||| myFullLayout ||| myGimpLayout) $
162 (myTabbedLayout ||| myMasterTabbedLayout ||| myTiledLayout)
163 )
164
165 main = do
166 xmonadDir <- getXMonadDir
167 xmobars <- mapM (\x -> spawnPipe ("xmobar -x " ++ (show x) ++ " " ++ xmonadDir ++ "/xmobar.hs")) [1, 2]
168 xmonad $ desktopConfig {
169 manageHook = myManageHook,
170 layoutHook = myLayout,
171 workspaces = myWorkspaces,
172 logHook = myLogHook xmobars,
173 startupHook = myStartupHook,
174 keys = myKeys,
175 modMask = mod4Mask,
176 handleEventHook = handleEventHook desktopConfig <+> fullscreenEventHook,
177 focusFollowsMouse = False
178 }
179