various fixes
[distro-setup] / subdir_files / .xmonad / xmonad.hs
1 import XMonad
2 --import XMonad.Config.Gnome
3
4 import Data.Monoid
5 import System.Exit
6
7 -- to get mouse move with window
8 import XMonad.Actions.UpdatePointer
9
10 -- needed for the panel toggle keybind
11 import XMonad.Hooks.ManageDocks
12
13 -- not sure if this is redundant with Xfce import
14 import XMonad.Config.Desktop
15
16 -- based on http://www.haskell.org/haskellwiki/Xmonad/Using_xmonad_in_XFCE
17 import XMonad.Hooks.EwmhDesktops
18 import XMonad.Config.Xfce
19 import XMonad.Hooks.ManageDocks
20
21 import qualified XMonad.StackSet as W
22 import qualified Data.Map as M
23
24 import XMonad.Actions.CycleWindows -- Reset the layouts on the current workspace to default
25
26 import XMonad.Hooks.SetWMName
27
28
29 -- /usr/share/xmonad/xmonad.hs on fedora has integration with gnome etc. but I
30 -- had lots of problems with gnome integration.
31
32 main = xmonad $ defaults
33
34
35 defaults = desktopConfig
36 {
37 terminal = "sakura"
38 , borderWidth = 0
39 , modMask = mod4Mask
40 , keys = myKeys
41 --, logHook = myLogHook <+> logHook desktopConfig
42 , mouseBindings = myMouseBindings
43
44
45 -- manageDocks & ewmh stuff is based on xfce integration wiki page
46 , manageHook = manageDocks <+> myManageHook <+> manageHook defaultConfig
47 , logHook = ewmhDesktopsLogHook
48 -- todo, look into the suggested avoidStruts. my nieve attempt to integrate it failed
49 , layoutHook = myLayout
50 , handleEventHook = ewmhDesktopsEventHook
51 -- this makes some java programs work, like intellij idea,
52 -- but it also makes the ui buggy for some gtk apps, like transmission
53 -- and gnome-terminal
54 -- https://bbs.archlinux.org/viewtopic.php?pid=744577
55 , startupHook = setWMName "LG3D"
56 -- combining the 2 with <+> didn't make java apps work.
57 --, startupHook = ewmhDesktopsStartup
58
59 }
60
61
62 -- for android emulator buggy window
63 myManageHook = composeAll [ className =? "emulator64-arm" --> unfloat]
64 where unfloat = ask >>= doF . W.sink
65
66 -- this is a nice idea but needs some tweaking cuz i don't want it to
67 -- have an affect when switching to a floating window,
68 -- and I remember sometimes being stuck in floating dialog boxes
69 -- myLogHook = updatePointer (Relative 0.5 0.5)
70
71
72
73 myKeys conf@(XConfig {XMonad.modMask = modm}) = M.fromList $
74
75
76 -- Move focus to the previous window
77 -- , ((modm, xK_q ), windows W.focusUp )
78
79
80 [ ((modm, xK_q), io (exitWith ExitSuccess)) -- %! Quit xmonad
81
82 , ((modm, xK_2), spawn "pavucontrol")
83 , ((modm, xK_3), spawn "firefox")
84
85 , ((modm, xK_4), spawn "input-setup.sh")
86
87 -- we would really want to keep track of which workspace is darkened,
88 -- and change things depending on where that workspace is
89
90 -- fedora vs debian ordering
91 -- , ((modm, xK_w), spawn "redshift.sh 0")
92 -- , ((modm, xK_e), spawn "redshift.sh 2")
93 -- , ((modm, xK_r), spawn "redshift.sh 1")
94 , ((modm, xK_w), spawn "/a/bin/redshift.sh 2")
95 , ((modm, xK_e), spawn "/a/bin/redshift.sh 1")
96 , ((modm, xK_r), spawn "/a/bin/redshift.sh 0")
97
98 -- Rotate through the available layout algorithms
99 , ((modm, xK_t ), sendMessage NextLayout)
100
101 , ((modm , xK_Home ), sendMessage ToggleStruts)
102
103 -- disabled default of cycling windows. instead use traditional stack based alt-tab behavior
104 -- todo, this locks up everytyhing, and the only thing that works is
105 -- futher cycle key presses until i restart X
106 -- , ((modm, xK_g ), cycleRecentWindows [xK_Super_L,xK_Super_R] xK_g xK_Tab)
107
108 -- close focused window
109 , ((modm , xK_c ), kill)
110
111
112 -- Reset the layouts on the current workspace to default
113 , ((modm, xK_b ), setLayout $ XMonad.layoutHook conf)
114
115
116 -- todo, make the pointer follow the window for these
117
118 -- fedora's order
119 -- , ((modm , xK_Delete), screenWorkspace 0 >>= flip whenJust (windows . W.shift))
120 -- , ((modm , xK_parenleft), screenWorkspace 2 >>= flip whenJust (windows . W.shift))
121 -- , ((modm , xK_parenright), screenWorkspace 1 >>= flip whenJust (windows . W.shift))
122 -- debian's order
123 , ((modm , xK_Delete), screenWorkspace 2 >>= flip whenJust (windows . W.shift))
124 , ((modm , xK_parenleft), screenWorkspace 1 >>= flip whenJust (windows . W.shift))
125 , ((modm , xK_parenright), screenWorkspace 0 >>= flip whenJust (windows . W.shift))
126
127 -- Move focus to the next window
128 , ((0, xK_F8 ), windows W.focusDown)
129
130 , ((modm , xK_6), windows $ W.greedyView "6")
131
132 -- Swap the focused window with the next window
133 , ((modm, xK_asterisk ), windows W.swapDown )
134
135 -- Swap the focused window with the previous window
136 , ((modm, xK_9 ), windows W.swapUp )
137
138
139 -- fedora's order
140 -- , ((modm , xK_u), screenWorkspace 0 >>= flip whenJust (windows . W.view))
141 -- , ((modm , xK_i), screenWorkspace 2 >>= flip whenJust (windows . W.view))
142 -- , ((modm , xK_o), screenWorkspace 1 >>= flip whenJust (windows . W.view))
143 -- debian's order
144 , ((modm , xK_u), screenWorkspace 2 >>= flip whenJust (windows . W.view))
145 , ((modm , xK_i), screenWorkspace 1 >>= flip whenJust (windows . W.view))
146 , ((modm , xK_o), screenWorkspace 0 >>= flip whenJust (windows . W.view))
147
148
149 -- Restart xmonad
150 , ((modm , xK_p), spawn "xmonad --recompile; xmonad --restart")
151 -- Push window back into tiling
152 , ((modm, xK_h ), withFocused $ windows . W.sink)
153
154 -- this working is dependent upon env vars set in distro-start
155 , ((modm, xK_j ), spawn "emacsclient -c")
156
157
158 -- launch a terminal
159 , ((modm, xK_k), spawn $ XMonad.terminal conf)
160
161
162 , ((modm, xK_l), spawn "dmenu_run")
163
164 -- Expand the master area
165 , ((modm, xK_n ), sendMessage Expand)
166
167 -- Shrink the master area
168 , ((modm, xK_m ), sendMessage Shrink)
169
170 -- Move focus to the master window
171 , ((modm, xK_y ), windows W.focusMaster )
172
173
174
175 -- Increment the number of windows in the master area
176 , ((modm , xK_comma ), sendMessage (IncMasterN 1))
177
178 -- Deincrement the number of windows in the master area
179 , ((modm , xK_period), sendMessage (IncMasterN (-1)))
180
181 -- Swap the focused window and the master window
182 --, ((modm, xK_Return), windows W.swapMaster)
183 -- in recent versions, a different name works better
184 , ((modm, xK_Return), windows W.shiftMaster)
185
186 ]
187 ++
188
189
190
191 -- open workspace, and send to workspace with same key plus control
192 [((m .|. modm, k), windows $ f i)
193 | (i, k) <- zip (XMonad.workspaces conf) [xK_f, xK_d, xK_s, xK_a, xK_z, xK_grave, xK_7, xK_0]
194 , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]]
195 -- fedora's default ordering of workspaces
196 -- xK_s, xK_f, xK_d,
197
198
199
200
201 myMouseBindings (XConfig {XMonad.modMask = modm}) = M.fromList $
202
203 -- mod-button1, Set the window to floating mode and move by dragging
204 [ ((modm, button1), (\w -> focus w >> mouseMoveWindow w
205 >> windows W.shiftMaster))
206
207 -- mod-button2, Raise the window to the top of the stack
208 , ((modm, button2), (\w -> focus w >> windows W.shiftMaster))
209
210 -- mod-button3, Set the window to floating mode and resize by dragging
211 , ((modm, button3), (\w -> focus w >> mouseResizeWindow w
212 >> windows W.shiftMaster))
213
214 -- you may also bind events to the mouse scroll wheel (button4 and button5)
215 ]
216
217 myLayout = desktopLayoutModifiers $ Full ||| Mirror tiled ||| tiled
218 where
219 -- default tiling algorithm partitions the screen into two panes
220 tiled = Tall nmaster delta ratio
221
222 -- The default number of windows in the master pane
223 nmaster = 1
224
225 -- Default proportion of screen occupied by master pane
226 ratio = 1/2
227
228 -- Percent of screen to increment by when resizing panes
229 delta = 3/100