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