-
Notifications
You must be signed in to change notification settings - Fork 13
/
xmonad.hs
363 lines (321 loc) · 16 KB
/
xmonad.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
-------------------------------------------------------------------------------
-- __ ____ __ _ --
-- \ \/ / \/ | ___ _ __ __ _ __| | --
-- \ /| |\/| |/ _ \| '_ \ / _` |/ _` | --
-- / \| | | | (_) | | | | (_| | (_| | --
-- /_/\_\_| |_|\___/|_| |_|\__,_|\__,_| --
-- --
-------------------------------------------------------------------------------
-- written by Shotaro Fujimoto (https://github.com/ssh0) --
-------------------------------------------------------------------------------
-- Import modules {{{
-------------------------------------------------------------------------------
import qualified Data.Map as M
import Control.Monad (liftM2) -- myManageHookShift
import Data.Monoid
import System.IO -- for xmobar
import XMonad
import qualified XMonad.StackSet as W -- myManageHookShift
import XMonad.Actions.CopyWindow
import XMonad.Actions.CycleWS
import qualified XMonad.Actions.FlexibleResize as Flex -- flexible resize
import XMonad.Actions.FloatKeys
import XMonad.Actions.UpdatePointer
import XMonad.Actions.WindowGo
import XMonad.Hooks.DynamicLog -- for xmobar
import XMonad.Hooks.EwmhDesktops
import XMonad.Hooks.ManageDocks -- avoid xmobar area
import XMonad.Hooks.ManageHelpers
import XMonad.Layout
import XMonad.Layout.DragPane -- see only two window
import XMonad.Layout.Gaps
import XMonad.Layout.LayoutScreens
import XMonad.Layout.NoBorders -- In Full mode, border is no use
import XMonad.Layout.PerWorkspace -- Configure layouts on a per-workspace
import XMonad.Layout.ResizableTile -- Resizable Horizontal border
import XMonad.Layout.Simplest
import XMonad.Layout.SimplestFloat
import XMonad.Layout.Spacing -- this makes smart space around windows
import XMonad.Layout.ToggleLayouts -- Full window at any time
import XMonad.Layout.TwoPane
import XMonad.Prompt
import XMonad.Prompt.Window -- pops up a prompt with window names
import XMonad.Util.EZConfig -- removeKeys, additionalKeys
import XMonad.Util.Run
import XMonad.Util.Run(spawnPipe) -- spawnPipe, hPutStrLn
import XMonad.Util.SpawnOnce
import Graphics.X11.ExtraTypes.XF86
--------------------------------------------------------------------------- }}}
-- local variables {{{
-------------------------------------------------------------------------------
myWorkspaces = ["1", "2", "3", "4", "5"]
modm = mod4Mask
-- Color Setting
colorBlue = "#868bae"
colorGreen = "#00d700"
colorRed = "#ff005f"
colorGray = "#666666"
colorWhite = "#bdbdbd"
colorNormalbg = "#1c1c1c"
colorfg = "#a8b6b8"
-- Border width
borderwidth = 4
-- Border color
mynormalBorderColor = "#262626"
myfocusedBorderColor = "#ededed"
-- Float window control width
moveWD = borderwidth
resizeWD = 2*borderwidth
-- gapwidth
gapwidth = 4
gwU = 2
gwD = 1
gwL = 38
gwR = 37
--------------------------------------------------------------------------- }}}
-- main {{{
-------------------------------------------------------------------------------
main :: IO ()
main = do
wsbar <- spawnPipe myWsBar
xmonad $ ewmh defaultConfig
{ borderWidth = borderwidth
, terminal = "urxvtc"
, focusFollowsMouse = True
, normalBorderColor = mynormalBorderColor
, focusedBorderColor = myfocusedBorderColor
, startupHook = myStartupHook
, manageHook = myManageHookShift <+>
myManageHookFloat <+>
manageDocks
, layoutHook = avoidStruts $ ( toggleLayouts (noBorders Full)
$ onWorkspace "3" simplestFloat
$ myLayout
)
-- xmobar setting
, logHook = myLogHook wsbar
>> updatePointer (Relative 0.5 0.5)
, handleEventHook = fullscreenEventHook
, workspaces = myWorkspaces
, modMask = modm
, mouseBindings = newMouse
}
-------------------------------------------------------------------- }}}
-- Define keys to remove {{{
------------------------------------------------------------------------
`removeKeysP`
[
-- Unused gmrun binding
"M-S-p",
-- Unused close window binding
"M-S-c",
"M-S-<Return>"
]
-------------------------------------------------------------------- }}}
-- Keymap: window operations {{{
------------------------------------------------------------------------
`additionalKeysP`
[
-- Shrink / Expand the focused window
("M-," , sendMessage Shrink)
, ("M-." , sendMessage Expand)
, ("M-z" , sendMessage MirrorShrink)
, ("M-a" , sendMessage MirrorExpand)
-- Close the focused window
, ("M-c" , kill1)
-- Toggle layout (Fullscreen mode)
, ("M-f" , sendMessage ToggleLayout)
, ("M-S-f" , withFocused (keysMoveWindow (-borderwidth,-borderwidth)))
-- Move the focused window
, ("M-C-<R>", withFocused (keysMoveWindow (moveWD, 0)))
, ("M-C-<L>", withFocused (keysMoveWindow (-moveWD, 0)))
, ("M-C-<U>", withFocused (keysMoveWindow (0, -moveWD)))
, ("M-C-<D>", withFocused (keysMoveWindow (0, moveWD)))
-- Resize the focused window
, ("M-s" , withFocused (keysResizeWindow (-resizeWD, resizeWD) (0.5, 0.5)))
, ("M-i" , withFocused (keysResizeWindow (resizeWD, resizeWD) (0.5, 0.5)))
-- Increase / Decrese the number of master pane
, ("M-S-;" , sendMessage $ IncMasterN 1)
, ("M--" , sendMessage $ IncMasterN (-1))
-- Go to the next / previous workspace
, ("M-<R>" , nextWS )
, ("M-<L>" , prevWS )
, ("M-l" , nextWS )
, ("M-h" , prevWS )
-- Shift the focused window to the next / previous workspace
, ("M-S-<R>", shiftToNext)
, ("M-S-<L>", shiftToPrev)
, ("M-S-l" , shiftToNext)
, ("M-S-h" , shiftToPrev)
-- CopyWindow
, ("M-v" , windows copyToAll)
, ("M-S-v" , killAllOtherCopies)
-- Move the focus down / up
, ("M-<D>" , windows W.focusDown)
, ("M-<U>" , windows W.focusUp)
, ("M-j" , windows W.focusDown)
, ("M-k" , windows W.focusUp)
-- Swap the focused window down / up
, ("M-S-j" , windows W.swapDown)
, ("M-S-k" , windows W.swapUp)
-- Shift the focused window to the master window
, ("M-S-m" , windows W.shiftMaster)
-- Search a window and focus into the window
, ("M-g" , windowPromptGoto myXPConfig)
-- Search a window and bring to the current workspace
, ("M-b" , windowPromptBring myXPConfig)
-- Move the focus to next screen (multi screen)
, ("M-<Tab>", nextScreen)
-- Now we have more than one screen by dividing a single screen
, ("M-C-<Space>", layoutScreens 2 (TwoPane 0.5 0.5))
, ("M-C-S-<Space>", rescreen)
]
-------------------------------------------------------------------- }}}
-- Keymap: Manage workspace {{{
------------------------------------------------------------------------
-- mod-[1..9] Switch to workspace N
-- mod-shift-[1..9] Move window to workspace N
-- mod-control-[1..9] Copy window to workspace N
`additionalKeys`
[ ((m .|. modm, k), windows $ f i)
| (i, k) <- zip myWorkspaces [xK_1 ..]
, (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask), (copy, controlMask)]
]
-------------------------------------------------------------------- }}}
-- Keymap: custom commands {{{
------------------------------------------------------------------------
`additionalKeysP`
[
-- Lock screen
("M1-C-l", spawn "xscreensaver-command -lock")
-- Toggle compton (compsite manager)
, ("M1-C-t", spawn "bash toggle_compton.sh")
-- Launch terminal
, ("M-<Return>", spawn "urxvtc")
-- Launch terminal with a float window
, ("M-S-<Return>", spawn "urxvt_float.sh")
-- Insert a transparent panel
, ("M-S-t", spawn "python $HOME/Workspace/python/transparent.py")
-- Launch file manager
, ("M-e", spawn "thunar")
-- Launch web browser
, ("M-w", spawn "luakit")
-- Launch dmenu for launching applicatiton
, ("M-p", spawn "exe=`dmenu_run -l 10 -fn 'Migu 1M:size=20'` && exec $exe")
-- Lauch websearch application (See https://github.com/ssh0/web_search)
, ("M1-C-f", spawn "websearch")
-- Play / Pause media keys
, ("<XF86AudioPlay>" , spawn "mpc toggle")
, ("<XF86HomePage>" , spawn "mpc toggle")
, ("S-<F6>" , spawn "mpc toggle")
, ("S-<XF86AudioPlay>", spawn "streamradio pause")
, ("S-<XF86HomePage>" , spawn "streamradio pause")
-- Volume setting media keys
, ("<XF86AudioRaiseVolume>", spawn "sound_volume_change_wrapper.sh +")
, ("<XF86AudioLowerVolume>", spawn "sound_volume_change_wrapper.sh -")
, ("<XF86AudioMute>" , spawn "sound_volume_change_wrapper.sh m")
-- Brightness Keys
, ("<XF86MonBrightnessUp>" , spawn "xbacklight + 5 -time 100 -steps 1")
, ("<XF86MonBrightnessDown>", spawn "xbacklight - 5 -time 100 -steps 1")
-- Take a screenshot (whole window)
, ("<Print>", spawn "screenshot.sh")
-- Take a screenshot (selected area)
, ("S-<Print>", spawn "screenshot_select.sh")
-- Launch ipython qtconsole
, ("<XF86Calculator>", spawn "ipython qtconsole --matplotlib=inline")
-- Toggle touchpad
, ("C-<Escape>", spawn "touchpad_toggle.sh")
-- Toggle trackpoint (Lenovo PC)
, ("M1-<Escape>", spawn "trackpoint_toggle.sh")
]
--------------------------------------------------------------------------- }}}
-- myLayout: Handle Window behaveior {{{
-------------------------------------------------------------------------------
myLayout = spacing gapwidth $ gaps [(U, gwU),(D, gwD),(L, gwL),(R, gwR)]
$ (ResizableTall 1 (1/205) (120/205) [])
||| (TwoPane (1/205) (120/205))
||| Simplest
--------------------------------------------------------------------------- }}}
-- myStartupHook: Start up applications {{{
-------------------------------------------------------------------------------
myStartupHook = do
spawnOnce "gnome-settings-daemon"
spawnOnce "nm-applet"
spawnOnce "xscreensaver -no-splash"
spawnOnce "$HOME/.dropbox-dist/dropboxd"
spawnOnce "bash $HOME/.fehbg"
-- spawnOnce "compton -b --config $HOME/.config/compton/compton.conf"
--------------------------------------------------------------------------- }}}
-- myManageHookShift: some window must created there {{{
-------------------------------------------------------------------------------
myManageHookShift = composeAll
-- if you want to know className, type "$ xprop|grep CLASS" on shell
[ className =? "Gimp" --> mydoShift "3"
]
where mydoShift = doF . liftM2 (.) W.greedyView W.shift
--------------------------------------------------------------------------- }}}
-- myManageHookFloat: new window will created in Float mode {{{
-------------------------------------------------------------------------------
myManageHookFloat = composeAll
[ className =? "Gimp" --> doFloat
, className =? "Tk" --> doFloat
, className =? "mplayer2" --> doCenterFloat
, className =? "mpv" --> doCenterFloat
, className =? "feh" --> doCenterFloat
, className =? "Display.im6" --> doCenterFloat
, className =? "Shutter" --> doCenterFloat
, className =? "Thunar" --> doCenterFloat
, className =? "Nautilus" --> doCenterFloat
, className =? "Plugin-container" --> doCenterFloat
, className =? "Screenkey" --> (doRectFloat $ W.RationalRect 0.7 0.9 0.3 0.1)
, className =? "Websearch" --> doCenterFloat
, className =? "XClock" --> doSideFloat NE
, title =? "Speedbar" --> doCenterFloat
, title =? "urxvt_float" --> doSideFloat SC
, isFullscreen --> doFullFloat
, isDialog --> doCenterFloat
, stringProperty "WM_NAME" =? "LINE" --> (doRectFloat $ W.RationalRect 0.60 0.1 0.39 0.82)
, stringProperty "WM_NAME" =? "Google Keep" --> (doRectFloat $ W.RationalRect 0.3 0.1 0.4 0.82)
, stringProperty "WM_NAME" =? "tmptex.pdf - 1/1 (96 dpi)" --> (doRectFloat $ W.RationalRect 0.29 0.25 0.42 0.5)
, stringProperty "WM_NAME" =? "Figure 1" --> doCenterFloat
]
--------------------------------------------------------------------------- }}}
-- myLogHook: loghock settings {{{
-------------------------------------------------------------------------------
myLogHook h = dynamicLogWithPP $ wsPP { ppOutput = hPutStrLn h }
--------------------------------------------------------------------------- }}}
-- myWsBar: xmobar setting {{{
-------------------------------------------------------------------------------
myWsBar = "xmobar $HOME/.xmonad/xmobarrc"
wsPP = xmobarPP { ppOrder = \(ws:l:t:_) -> [ws,t]
, ppCurrent = xmobarColor colorRed colorNormalbg . \s -> "●"
, ppUrgent = xmobarColor colorGray colorNormalbg . \s -> "●"
, ppVisible = xmobarColor colorRed colorNormalbg . \s -> "⦿"
, ppHidden = xmobarColor colorGray colorNormalbg . \s -> "●"
, ppHiddenNoWindows = xmobarColor colorGray colorNormalbg . \s -> "○"
, ppTitle = xmobarColor colorRed colorNormalbg
, ppOutput = putStrLn
, ppWsSep = " "
, ppSep = " "
}
--------------------------------------------------------------------------- }}}
-- myXPConfig: XPConfig {{{
myXPConfig = defaultXPConfig
{ font = "xft:Migu 1M:size=20:antialias=true"
, fgColor = colorfg
, bgColor = colorNormalbg
, borderColor = colorNormalbg
, height = 35
, promptBorderWidth = 0
, autoComplete = Just 100000
, bgHLight = colorNormalbg
, fgHLight = colorRed
, position = Bottom
}
--------------------------------------------------------------------------- }}}
-- newMouse: Right click is used for resizing window {{{
-------------------------------------------------------------------------------
myMouse x = [ ((modm, button3), (\w -> focus w >> Flex.mouseResizeWindow w)) ]
newMouse x = M.union (mouseBindings defaultConfig x) (M.fromList (myMouse x))
--------------------------------------------------------------------------- }}}
-- vim: ft=haskell