]> code.delx.au - dotfiles/blob - .xmonad/xmonad.hs
xmonad: float screenruler
[dotfiles] / .xmonad / xmonad.hs
1 import System.IO
2 import XMonad
3 import XMonad.Hooks.DynamicLog
4 import XMonad.Hooks.ICCCMFocus
5 import XMonad.Hooks.ManageDocks
6 import XMonad.Hooks.Script
7 import XMonad.Hooks.SetWMName
8 import XMonad.Layout.IM
9 import XMonad.Layout.LayoutHints
10 import qualified XMonad.Layout.Magnifier as Mag
11 import XMonad.Layout.NoBorders
12 import XMonad.Layout.NoFrillsDecoration
13 import XMonad.Layout.PerWorkspace
14 import XMonad.Layout.Renamed
15 import XMonad.Layout.Tabbed
16 import XMonad.Layout.ThreeColumns
17 import XMonad.Util.Run(spawnPipe)
18 import qualified Data.Map as M
19 import qualified XMonad.StackSet as W
20
21
22 myKeys conf@(XConfig {XMonad.modMask = modm}) = M.fromList $
23 [
24 ((modm .|. shiftMask, xK_q), spawn "gnome-session-quit"),
25 ((modm .|. shiftMask, xK_h), spawn "gnome-session-quit --power-off"),
26 -- ((modm .|. shiftMask, xK_q), spawn "gnome-session-save --logout-dialog"),
27 -- ((modm .|. shiftMask, xK_h), spawn "gnome-session-save --shutdown-dialog"),
28 ((modm .|. shiftMask, xK_l), spawn "gnome-screensaver-command --lock"),
29
30 ((modm, xK_n), spawn "gnome-terminal"),
31 ((modm, xK_i), spawn "firefox"),
32
33 ((modm .|. shiftMask, xK_c ), kill),
34 ((modm, xK_space ), sendMessage NextLayout),
35 ((modm .|. shiftMask, xK_space ), setLayout $ XMonad.layoutHook conf),
36 ((modm, xK_Tab ), windows W.focusDown),
37 ((modm, xK_j ), windows W.focusDown),
38 ((modm, xK_k ), windows W.focusUp ),
39 ((modm, xK_m ), windows W.focusMaster ),
40 ((modm, xK_Return), windows W.swapMaster),
41 ((modm .|. shiftMask, xK_j ), windows W.swapDown ),
42 ((modm .|. shiftMask, xK_k ), windows W.swapUp ),
43 ((modm, xK_h ), sendMessage Shrink),
44 ((modm, xK_l ), sendMessage Expand),
45 ((modm, xK_t ), withFocused $ windows . W.sink),
46 ((modm , xK_comma ), sendMessage (IncMasterN 1)),
47 ((modm , xK_period), sendMessage (IncMasterN (-1))),
48 ((modm , xK_b ), sendMessage ToggleStruts),
49 ((modm , xK_z ), sendMessage Mag.Toggle)
50 ]
51 ++
52
53 -- mod-{w,e,r}, Switch to physical/Xinerama screens 1, 2, or 3
54 -- mod-shift-{w,e,r}, Move client to screen 1, 2, or 3
55 [((m .|. modm, key), screenWorkspace sc >>= flip whenJust (windows . f))
56 | (key, sc) <- zip [xK_o, xK_e, xK_u] [0..]
57 , (f, m) <- [(W.view, 0), (W.shift, shiftMask)]
58 ]
59 ++
60
61 -- mod-[1..9], Switch to workspace N
62 -- mod-shift-[1..9], Move client to workspace N
63 [((m .|. modm, k), windows $ f i)
64 | (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9]
65 , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]
66 ]
67
68
69
70 myManageHook = composeAll [
71 (className =? "Gnome-fallback-mount-helper" <&&> resource =? "gnome-fallback-mount-helper") --> doFloat,
72 (className =? "Gdu-notification-daemon" <&&> resource =? "gdu-notification-daemon") --> doFloat,
73 (className =? "Firefox" <&&> resource =? "Dialog") --> doFloat,
74 (className =? "Screenruler" <&&> resource =? "screenruler") --> doFloat,
75 manageDocks
76 ]
77
78
79 myWorkspaces = ["1", "2", "3", "4", "5", "6", "7", "8", "9"]
80
81 myPP = xmobarPP
82 {
83 ppTitle = xmobarColor "green" ""
84 }
85
86 myLogHook h1 =
87 dynamicLogWithPP myPP { ppOutput = hPutStrLn h1 } >>
88 takeTopFocus -- fix for Java Swing apps
89
90 myStartupHook =
91 setWMName "LG3D" -- fix for Java Swing apps
92
93
94 goldenRatio = (toRational (2/(1+sqrt(5)::Double)))
95
96 createLayout name layout =
97 renamed [Replace name] $
98 layoutHints $
99 smartBorders $
100 layout
101
102 myFullLayout = createLayout "Full" $
103 Full
104
105 myTiledLayout = createLayout "Tall" $
106 avoidStruts $
107 Mag.magnifierOff $
108 Tall nMaster ratioIncrement ratio
109 where
110 nMaster = 1
111 ratioIncrement = 3/100
112 ratio = goldenRatio
113
114 myTabbedLayout = createLayout "Tab" $
115 avoidStruts $
116 simpleTabbed
117
118 myThreeColLayout = createLayout "ThreeCol" $
119 avoidStruts $
120 Mag.magnifierOff $
121 ThreeCol numMaster resizeDelta masterRatio
122 where
123 resizeDelta = 3/100
124 masterRatio = 4/10
125 numMaster = 1
126
127 myImLayout = createLayout "IM" $
128 avoidStruts $
129 noFrillsDeco shrinkText defaultTheme $
130 withIM rosterRatio roster $
131 myTiledLayout
132 --- myThreeColLayout -- use this on wider screens
133 where
134 rosterRatio = 1/8
135 roster = (Or (Title "Buddy List") (And (Resource "main") (ClassName "psi")))
136
137 -- This was the easiest way I found to avoid a compile error when I have
138 -- an unused layout
139 referenceAllLayoutsToAvoidErrors =
140 myFullLayout |||
141 myTiledLayout |||
142 myTabbedLayout |||
143 myThreeColLayout |||
144 myImLayout
145
146
147 myLayout =
148 (
149 onWorkspace "1" (myImLayout) $
150 onWorkspace "2" (myTabbedLayout ||| myFullLayout) $
151 (myTiledLayout ||| myTabbedLayout)
152 )
153
154 main = do
155 xmonadDir <- getXMonadDir
156 xmobar <- spawnPipe ("xmobar " ++ xmonadDir ++ "/xmobar.hs")
157 xmonad $ defaultConfig {
158 manageHook = myManageHook <+> manageHook defaultConfig,
159 layoutHook = myLayout,
160 workspaces = myWorkspaces,
161 logHook = myLogHook xmobar,
162 startupHook = myStartupHook,
163 keys = myKeys
164 }
165