-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxmonad.hs
388 lines (330 loc) · 14.6 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
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
import XMonad
import Data.Monoid
import System.Exit
import XMonad.Hooks.ManageDocks
import XMonad.Util.SpawnOnce
import XMonad.Util.EZConfig
import XMonad.Util.Run
import XMonad.Layout.LayoutModifier
import XMonad.Layout.LimitWindows (limitWindows, increaseLimit, decreaseLimit)
import XMonad.Layout.Magnifier
import XMonad.Layout.MultiToggle (mkToggle, single, EOT(EOT), (??))
import XMonad.Layout.MultiToggle.Instances (StdTransformers(NBFULL, MIRROR, NOBORDERS))
import XMonad.Layout.NoBorders
import XMonad.Layout.Renamed (renamed, Rename(Replace))
import XMonad.Layout.Spacing
import XMonad.Layout.WindowArranger (windowArrange, WindowArrangerMsg(..))
import qualified XMonad.Layout.ToggleLayouts as T (toggleLayouts, ToggleLayout(Toggle))
import qualified XMonad.Layout.MultiToggle as MT (Toggle(..))
import XMonad.Layout.SimplestFloat
import XMonad.Util.NamedScratchpad
import XMonad.Layout.ResizableTile
import XMonad.Actions.MouseResize
import XMonad.Util.Scratchpad
import XMonad.Actions.WithAll (sinkAll, killAll)
import XMonad.Hooks.SetWMName
import XMonad.Hooks.DynamicLog (dynamicLogWithPP, wrap, xmobarPP, xmobarColor, shorten, PP(..))
import qualified XMonad.StackSet as W
import qualified Data.Map as M
-- The preferred terminal program, which is used in a binding below and by
-- certain contrib modules.
--
myTerminal :: [Char]
myTerminal = "alacritty"
-- Whether focus follows the mouse pointer.
myFocusFollowsMouse :: Bool
myFocusFollowsMouse = False
-- Whether clicking on a window to focus also passes the click to the window
myClickJustFocuses :: Bool
myClickJustFocuses = False
-- Width of the window border in pixels.
--
myBorderWidth :: Dimension
myBorderWidth = 2
-- modMask lets you specify which modkey you want to use. The default
-- is mod1Mask ("left alt"). You may also consider using mod3Mask
-- ("right alt"), which does not conflict with emacs keybindings. The
-- "windows key" is usually mod4Mask.
--
myModMask :: KeyMask
myModMask = mod4Mask
-- The default number of workspaces (virtual screens) and their names.
-- By default we use numeric strings, but any string may be used as a
-- workspace name. The number of workspaces is determined by the length
-- of this list.
--
-- A tagging example:
--
-- > workspaces = ["web", "irc", "code" ] ++ map show [4..9]
--
myWorkspaces :: [[Char]]
myWorkspaces = ["1","2","3","4","5","6","7","8","9"]
-- Border colors for unfocused and focused windows, respectively.
--
myNormalBorderColor :: [Char]
myNormalBorderColor = "#000000"
myFocusedBorderColor :: [Char]
myFocusedBorderColor = "#808080"
------------------------------------------------------------------------
-- Key bindings. Add, modify or remove key bindings here.
--
myKeys :: [(String, X ())]
myKeys =
[
("M-S-r", spawn "xmonad --recompile; xmonad --restart;") -- Restarts xmonad
, ("M-S-e", io exitSuccess)-- Quits xmonad
, ("M-<Space>", spawn "dmenu_run")
--, ("M-t", spawn myTerminal)
, ("M-q", kill) -- Kill the currently focused client
--, ("M-t", sendMessage (T.Toggle "floats")) -- Toggles my 'floats' layout
--, ("M-m", windows W.focusMaster) -- Move focus to the master window
, ("M-j", windows W.focusDown) -- Move focus to the next window
, ("M-k", windows W.focusUp) -- Move focus to the prev window
, ("M-<Return>", windows W.swapMaster) -- Swap the focused window and the master window
--, ("M-<Tab>", sendMessage NextLayout) -- Switch to next layout
, ("M-f", sendMessage (MT.Toggle NBFULL) >> sendMessage ToggleStruts) -- Toggles noborder/full
, ("M-<Delete>", withFocused $ windows . W.sink) -- Push floating window back to tile
, ("M-S-<Delete>", sinkAll) -- Push ALL floating windows to tile
, ("M-S-n", sendMessage $ MT.Toggle NOBORDERS) -- Toggles noborder
, ("M-h", sendMessage Shrink) -- Shrink horiz window width
, ("M-l", sendMessage Expand) -- Expand horiz window width
, ("<XF86AudioLowerVolume>", spawn "amixer set Master 5%- unmute")
, ("<XF86AudioRaiseVolume>", spawn "amixer set Master 5%+ unmute")
, ("M-e", spawn "emacsclient -a -n -c")
, ("M-p", spawn "passmenu") -- Move focus to the next window
--, ("M-t", spawn "emacsclient -c -a '' --eval '(eshell)'")
, ("M-t", spawn "emacsclient -c -a '' --eval '(+vterm/here nil)'")
, ("M-d", spawn "emacsclient -c -a '' --eval '(dired nil)'")
, ("M-n", spawn "emacsclient -c -a '' --eval '(elfeed)'")
--, ("M-S-t", namedScratchpadAction myScratchPads "terminal")
, ("M-S-p", namedScratchpadAction myScratchPads "pavucontrol")
, ("M-S-m", namedScratchpadAction myScratchPads "mocp")
, ("M-S-s", namedScratchpadAction myScratchPads "spotify")
, ("M-S-<Return>", namedScratchpadAction myScratchPads "eshell")
, ("M-b", spawn "emacsclient -c -a '' --eval '(ibuffer)'")
, ("M-S-l", spawn "xlock")
, ("M-S-<F9>", spawn "systemctl suspend")
, ("M-s f", spawn "xrandr --output DP-0 --mode 2048x1152 --output LVDS-0 --off")
, ("M-s l", spawn "xrandr --output DP-0 --mode 1280x800 --output LVDS-0 --off")
, ("M-s n", spawn "xrandr --output DP-0 --off --output LVDS-0 --mode 1600x900")
, ("M-o c", spawn "org-capture")
--, ("M-c", namedScratchpadAction myScratchPads "calendar")
]
where
scratchPad = scratchpadSpawnActionTerminal myTerminal
myScratchPads :: [NamedScratchpad]
myScratchPads = [ NS "terminal" spawnTerm findTerm manageTerm
, NS "mocp" spawnMocp findMocp manageMocp
, NS "pavucontrol" spawnPavu findPavu managePavu
, NS "spotify" spawnSpo findSpo manageSpo
, NS "emacs" spawnEmacs findEmacs manageEmacs
, NS "eshell" spawnEshell findEshell manageEshell
, NS "calendar" spawnCalendar findCalendar manageCalendar
]
where
spawnEshell = "emacsclient -a -n -c --eval '(eshell)' --frame-parameters='(quote (name . \"eshell-scratch\"))'"
findEshell = title =? "eshell-scratch"
manageEshell = customFloating $ W.RationalRect l t w h
where
h = 0.9
w = 0.9
t = 0.95 -h
l = 0.95 -w
spawnCalendar = "emacsclient -a -n -c --eval '(calendar)' --frame-parameters='(quote (name . \"calendar-scratch\"))'"
findCalendar = title =? "calendar-scratch"
manageCalendar = customFloating $ W.RationalRect l t w h
where
h = 0.25
w = 0.55
t = 0.95 -h
l = 0.95 -w
spawnSpo = "spotify"
findSpo = resource =? "spotify"
manageSpo = customFloating $ W.RationalRect l t w h
where
h = 0.9
w = 0.9
t = 0.95 -h
l = 0.95 -w
spawnPavu = "pavucontrol"
findPavu = resource =? "pavucontrol"
managePavu = customFloating $ W.RationalRect l t w h
where
h = 0.9
w = 0.9
t = 0.95 -h
l = 0.95 -w
spawnTerm = myTerminal ++ " -t scratchpad"
findTerm = title =? "scratchpad"
manageTerm = customFloating $ W.RationalRect l t w h
where
h = 0.9
w = 0.9
t = 0.95 -h
l = 0.95 -w
spawnMocp = myTerminal ++ " -t cmus -e cmus"
findMocp = title =? "cmus"
manageMocp = customFloating $ W.RationalRect l t w h
where
h = 0.9
w = 0.9
t = 0.95 -h
l = 0.95 -w
spawnEmacs = "emacsclient -a -n -c --frame-parameters='(quote (name . \"escratchpad\"))'"
findEmacs = title =? "escratchpad"
manageEmacs = customFloating $ W.RationalRect l t w h
where
h = 0.9
w = 0.9
t = 0.95 -h
l = 0.95 -w
-- Mouse bindings: default actions bound to mouse events
--
myMouseBindings (XConfig {XMonad.modMask = modm}) = M.fromList $
-- mod-button1, Set the window to floating mode and move by dragging
[ ((modm, button1), (\w -> focus w >> mouseMoveWindow w
>> windows W.shiftMaster)),
-- mod-button2, Raise the window to the top of the stack
((modm, button2), (\w -> focus w >> windows W.shiftMaster))
-- mod-button3, Set the window to floating mode and resize by dragging
, ((modm, button3), (\w -> focus w >> mouseResizeWindow w
>> windows W.shiftMaster))
-- you may also bind events to the mouse scroll wheel (button4 and button5)
]
-- Layouts:
-- You can specify and transform your layouts by modifying these values.
-- If you change layout bindings be sure to use 'mod-shift-space' after
-- restarting (with 'mod-q') to reset your layout state to the new
-- defaults, as xmonad preserves your old layout settings by default.
--
-- The available layouts. Note that each layout is separated by |||,
-- which denotes layout choice.
-- ||| Mirror tiled (to enable horizontal master/stack)
-- Makes setting the spacingRaw simpler to write. The spacingRaw
-- module adds a configurable amount of space around windows.
mySpacing :: Integer -> l a -> XMonad.Layout.LayoutModifier.ModifiedLayout Spacing l a
mySpacing i = spacingRaw False (Border i i i i) True (Border i i i i) True
-- Below is a variation of the above except no borders are applied
-- if fewer than two windows. So a single window has no gaps.
mySpacing' :: Integer -> l a -> XMonad.Layout.LayoutModifier.ModifiedLayout Spacing l a
mySpacing' i = spacingRaw True (Border i i i i) True (Border i i i i) True
tall = renamed [Replace "tall"]
$ limitWindows 12
$ mySpacing 5
$ ResizableTall 1 (3/100) (1/2) []
magnify = renamed [Replace "magnify"]
$ magnifier
$ limitWindows 12
$ mySpacing 8
$ ResizableTall 1 (3/100) (1/2) []
monocle = renamed [Replace "monocle"]
$ limitWindows 20
$ Full
floats = renamed [Replace "floats"]
$ limitWindows 20
$ simplestFloat
myLayoutHook = avoidStruts $ mouseResize $ windowArrange $ T.toggleLayouts floats $
mkToggle (NBFULL ?? NOBORDERS ?? EOT) $ myDefaultLayout
where
-- I've commented out the layouts I don't use.
myDefaultLayout = tall
-- ||| magnify
||| noBorders monocle
-- ||| floats
myLayout = avoidStruts (tiled ||| Full)
where
-- default tiling algorithm partitions the screen into two panes
tiled = Tall nmaster delta ratio
-- The default number of windows in the master pane
nmaster = 1
-- Default proportion of screen occupied by master pane
ratio = 1/2
-- Percent of screen to increment by when resizing panes
delta = 3/100
-- Window rules:
-- Execute arbitrary actions and WindowSet manipulations when managing
-- a new window. You can use this to, for example, always float a
-- particular program, or have a client always appear on a particular
-- workspace.
--
-- To find the property name associated with a program, use
-- > xprop | grep WM_CLASS
-- and click on the client you're interested in.
--
-- To match on the WM_NAME, you can use 'title' in the same way that
-- 'className' and 'resource' are used below.
--
myManageHook = (composeAll
[ className =? "MPlayer" --> doFloat
, className =? "Gimp" --> doFloat
, resource =? "desktop_window" --> doIgnore]) <+> namedScratchpadManageHook myScratchPads
--manageScratchPad
-- Event handling
-- * EwmhDesktops users should change this to ewmhDesktopsEventHook
--
-- Defines a custom handler function for X Events. The function should
-- return (All True) if the default handler is to be run afterwards. To
-- combine event hooks use mappend or mconcat from Data.Monoid.
--
myEventHook = mempty
-- Status bars and logging
-- Perform an arbitrary action on each internal state change or X event.
-- See the 'XMonad.Hooks.DynamicLog' extension for examples.
--
myLogHook :: X ()
myLogHook = return ()
-- Startup hook
-- Perform an arbitrary action each time xmonad starts or is restarted
-- with mod-q. Used by, e.g., XMonad.Layout.PerWorkspace to initialize
-- per-workspace layout choices.
--
-- By default, do nothing.
myStartupHook :: X ()
myStartupHook = do
--spawnOnce "xrandr --output LVDS-0 --auto"
--spawnOnce "xrandr --output VGA-0 --mode 1920x1080 --output LVDS-0 --off"
spawnOnce "xrandr --output DP-0 --mode 2048x1152 --output LVDS-0 --off"
spawnOnce "nitrogen --restore &"
spawnOnce "protonmail-bridge &"
spawnOnce "setxkbmap -layout us_intl"
spawnOnce "picom --vsync -b"
spawnOnce "xwallpaper --maximize ~/.config/wall.png"
setWMName "LG3D"
--spawnOnce "picom --vsync -b"
-- Now run xmonad with all the defaults we set up.
-- Run xmonad with the settings you specify. No need to modify this.
--
main :: IO ()
main = do
xmproc <- spawnPipe "xmobar ~/.xmonad/xmobar.config"
xmonad $ docks $ defaults xmproc
-- A structure containing your configuration settings, overriding
-- fields in the default config. Any you don't override, will
-- use the defaults defined in xmonad/XMonad/Config.hs
--
-- No need to modify this.
--
defaults xmproc = def {
-- simple stuff
terminal = myTerminal,
focusFollowsMouse = myFocusFollowsMouse,
clickJustFocuses = myClickJustFocuses,
borderWidth = myBorderWidth,
modMask = myModMask,
workspaces = myWorkspaces,
normalBorderColor = myNormalBorderColor,
focusedBorderColor = myFocusedBorderColor,
-- key bindings
mouseBindings = myMouseBindings,
-- hooks, layouts
layoutHook = myLayoutHook,
manageHook = myManageHook,
handleEventHook = myEventHook,
logHook = dynamicLogWithPP xmobarPP
{
ppCurrent = xmobarColor "#8be9fd" "" . wrap "[" "]"
, ppTitle = xmobarColor "#8be9fd" "" . shorten 60
, ppOutput = hPutStrLn xmproc
} ,
startupHook = myStartupHook
} `additionalKeysP` myKeys