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