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
|
import XMonad
-- Actions
import qualified XMonad.Actions.CycleWS as CWS
import XMonad.Actions.NoBorders
import XMonad.Actions.SpawnOn
-- Hooks
import XMonad.Hooks.DynamicLog (dynamicLogWithPP, filterOutWsPP, wrap, xmobarPP, xmobarColor, shorten, shorten', shortenLeft', PP(..))
import XMonad.Hooks.EwmhDesktops
import XMonad.Hooks.ManageHelpers
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.ManageHelpers (isFullscreen, doFullFloat)
import XMonad.Hooks.SetWMName
import XMonad.Hooks.StatusBar
import XMonad.Hooks.StatusBar.PP (xmobarFont)
import XMonad.Hooks.WorkspaceHistory
import XMonad.Layout.Gaps
import XMonad.Layout.PerWorkspace
import XMonad.Layout.NoBorders
import XMonad.Layout.Spacing
import XMonad.Layout.Spiral
import qualified XMonad.StackSet as W
-- import XMonad.EZConfig (AddAdditionalKeysP)
-- Utils
import XMonad.Util.Cursor
import XMonad.Util.Dmenu
import XMonad.Util.EZConfig (additionalKeysP)
import XMonad.Util.NamedScratchpad
import XMonad.Util.Run
import XMonad.Util.SpawnOnce
-- Data
import Data.Maybe (fromJust)
import Data.Monoid
import qualified Data.Map as M
import System.Exit
import System.IO
-- Variables
--
-- Default Terminal
myTerminal :: String
myTerminal = "alacritty"
-- Whether focus follows the mouse pointer.
myFocusFollowsMouse :: Bool
myFocusFollowsMouse = True
-- Whether clicking on a window to focus also passes the click to the window
myClickJustFocuses :: Bool
myClickJustFocuses = True
-- Width of the window border in pixels.
--
myBorderWidth = 2
myModMask = mod4Mask
-- myScratchPads :: [NamedScratchpad]
-- myScratchPads = [ NS "terminal" "kitty" (title =? "getScratched") defaultFloating ]
--
-- Workspaces
myWorkspaces = ["cab","web","lab","ser","gfx","idi","gam","muz","cha","hid"]
colorbg = "#2e3440"
colorfg = "#eceff4"
color01 = "#5e8bac"
color02 = "#b48ead"
color04 = "#ebcb8b"
color05 = "#81a1c1"
color09 = "#4c566a"
color17 = "#d03a3f"
leftwp = "<box type=Bottom width=2 mb=2 color=" ++ colorfg ++ ">"
rightwp = "</box>"
-- Count of window in active workspace
windowCount :: X (Maybe String)
windowCount = gets $ Just . show . length . W.integrate' . W.stack . W.workspace . W.current . windowset
------ COLORS
-- Border colors for unfocused and focused windows, respectively.
myNormalBorderColor = color09
myFocusedBorderColor = color05
------------------------------------------------------------------------
-- Key bindings. Add, modify or remove key bindings here.
myKeys conf@(XConfig {XMonad.modMask = modm}) = M.fromList $
--
-- mod-[1..9], Switch to workspace N
-- mod-shift-[1..9], Move client to workspace N
--
[((m .|. modm, k), windows $ f i)
| (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9]
, (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]]
++
--
-- mod-{w,e,r}, Switch to physical/Xinerama screens 1, 2, or 3
-- mod-shift-{w,e,r}, Move client to screen 1, 2, or 3
--
[((m .|. modm, key), screenWorkspace sc >>= flip whenJust (windows . f))
| (key, sc) <- zip [xK_w, xK_e, xK_r] [0..]
-- | (key, sc) <- zip [xK_e, xK_w, xK_r] [0..]
, (f, m) <- [(W.view, 0), (W.shift, shiftMask)]]
------------------------------------------------------------------------
-- 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:
myLayoutPrinter :: String -> String
myLayoutPrinter "Spacing Tall" = xmobarColor colorfg colorbg "til"
myLayoutPrinter "Spacing Mirror Tall" = xmobarColor colorfg colorbg "mti"
myLayoutPrinter "Spacing Spiral" = xmobarColor colorfg colorbg "fib"
myLayoutPrinter "Spacing Full" = xmobarColor colorfg colorbg "ful"
myLayoutPrinter x = xmobarColor colorfg colorbg x
myLayout =
onWorkspace "gam" Full $
avoidStruts(gaps [(L,3), (D,3), (U,3), (R,3)] $ smartSpacing 2 $ tiled ||| Mirror tiled ||| fib ||| 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 = 2/5
-- Percent of screen to increment by when resizing panes
delta = 3/100
fib = spiral (6/7)
------------------------------------------------------------------------
-- Window rules:
myManageHook = composeAll
[
-- className =? "Gimp" --> doFloat
-- , className =? "Tilp" --> doFloat
-- , resource =? "desktop_window" --> doIgnore
-- , resource =? "kdesktop" --> doIgnore
--
className =? "discord" --> doShift "cha",
className =? "Steam" --> doShift "gam"
]
-- <+> namedScratchpadManageHook myScratchPads
------------------------------------------------------------------------
-- Startup hook
myStartupHook = do
setWMName "XMonad"
setDefaultCursor xC_arrow
spawnOnce "checkupdates | wc -l > /tmp/updates.tmp"
spawnOnce "systemctl --user restart redshift.service"
spawnOnce "unclutter --timeout 3 --jitter 50 -b"
spawnOnce "numlockx"
spawnOnce "$HOME/.config/xmonad/autostart/autostart.sh"
------------------------------------------------------------------------
-- Now run xmonad with all the defaults we set up.
-- Run xmonad with the settings you specify. No need to modify this.
--
main = do
-- Setup xmobar as docks
--
xmproc0 <- spawnPipe "xmobar $HOME/.config/xmobar/xmobarrc0.hs"
xmproc1 <- spawnPipe "xmobar $HOME/.config/xmobar/xmobarrc1.hs"
-- ewmh: Add fullscreen handling support
xmonad $ docks . ewmh $ defaults {
layoutHook = avoidStruts $ layoutHook defaults
, logHook = dynamicLogWithPP $ filterOutWsPP ["hid"] $ xmobarPP {
ppOutput = \x -> hPutStrLn xmproc0 x
, ppCurrent = xmobarColor colorfg colorbg . wrap leftwp rightwp -- Visible but not current workspace
, ppVisible = xmobarColor colorfg colorbg -- Hidden workspace
, ppHidden = xmobarColor color01 colorbg -- Hidden workspaces (no windows)
, ppHiddenNoWindows = xmobarColor color04 colorbg -- Title of active window
, ppTitle = xmobarColor "" "" . shorten' "" 0 -- Separator character
, ppSep = " "
, ppLayout = myLayoutPrinter
-- Urgent workspace , ppUrgent = xmobarColor color17 colorbg . wrap "!" "!"
, ppExtras = [windowCount] -- Adding # of windows on current workspace to the bar
}
}
defaults = ewmh def {
-- simple stuff
terminal = myTerminal,
focusFollowsMouse = myFocusFollowsMouse,
clickJustFocuses = myClickJustFocuses,
borderWidth = myBorderWidth,
modMask = myModMask,
workspaces = myWorkspaces,
normalBorderColor = myNormalBorderColor,
focusedBorderColor = myFocusedBorderColor,
-- key bindings
keys = myKeys,
mouseBindings = myMouseBindings,
-- hooks, layouts
layoutHook = myLayout,
manageHook = myManageHook <+> manageSpawn,
startupHook = myStartupHook
}
`additionalKeysP`
[ ("M-<Return>", spawn myTerminal)
, ("M-<Backspace>", withFocused hide) -- N.B. this is an absurd thing to do
, ("M-0", windows $ W.greedyView $ "hid") -- N.B. this is an absurd thing to do
, ("M-u", incScreenWindowSpacing (2))
, ("M-i", incScreenWindowSpacing (-2))
, ("M-o", setScreenWindowSpacing (2))
-- Then these key bindings
-- cycling worspaces
, ("M-<R>", CWS.nextWS)
, ("M-<L>", CWS.prevWS)
, ("M-S-<R>", CWS.shiftToNext >> CWS.nextWS)
, ("M-S-<L>", CWS.shiftToPrev >> CWS.prevWS)
, ("M-m", spawn "emacs")
-- launch firefox
, ("M-b", spawn "firefox")
-- take screenshots
, ("M-s", spawn "maim ~/pictures/screenshot-$(date +%y%m%d_%H_%M_%S).png")
, ("M-C-s", spawn "maim -i $(xdotool getactivewindow) ~/pictures/screenshot-$(date +%y%m%d_%H_%M_%S).png")
, ("M-S-s", spawn "maim --select | xclip -selection clipboard -t image/png")
-- close focused window
, ("M-c", spawn "kill $(xprop | grep PID | cut -d = -f 2)")
, ("M-S-c", kill)
-- Rotate through the available layout algorithms
, ("M-C-1", sendMessage $ JumpToLayout "Tall")
, ("M-C-2", sendMessage $ JumpToLayout "Mirror Tall")
, ("M-C-3", sendMessage $ JumpToLayout "Spiral")
, ("M-C-4", sendMessage $ JumpToLayout "Full")
, ("M-<Tab>", sendMessage NextLayout)
, ("M-<Space>", spawn "cycleKB")
-- Resize viewed windows to the correct size
, ("M-n", refresh)
-- Move focus to the next window
, ("M-j", windows W.focusDown)
-- Move focus to the previous window
, ("M-k", windows W.focusUp)
-- Swap the focused window with the next window
, ("M-S-j", windows W.swapDown)
-- Swap the focused window with the previous window
, ("M-S-k", windows W.swapUp)
-- Shrink the master area
, ("M-h", sendMessage Shrink)
-- Expand the master area
, ("M-l", sendMessage Expand)
-- Push window back into tiling
, ("M-S-t", withFocused $ windows . W.sink)
-- Increment the number of windows in the master area
, ("M-,", sendMessage (IncMasterN 1))
-- Deincrement the number of windows in the master area
, ("M-.", sendMessage (IncMasterN (-1)))
-- Quit xmonad
, ("M-S-q", io (exitWith ExitSuccess))
-- Restart xmonad
, ("M-q", spawn "killall xmobar; xmonad --recompile && xmonad --restart")
, ("M-x m", spawn "kill -USR1 $(pgrep xmobar)")
-- open alsamixer and change volume with keyboard wheel
, ("<XF86AudioLowerVolume>" , spawn "pamixer -d 5")
, ("<XF86AudioRaiseVolume>" , spawn "pamixer -i 5")
, ("<XF86AudioMute>" , spawn "pamixer -t")
, ("<XF86MonBrightnessDown>", spawn "light -U 5")
, ("<XF86MonBrightnessUp>" , spawn "light -A 5")
, ("M-y" , spawn "arr_hjkl")
-- Toggle borders
, ("M-S-b", do
withFocused toggleBorder
refresh)
-- Fullscreen by toggling borders,
-- struts so docks can be obfuscated
-- (forcing it into tiling, because problems if you change layouts)
, ("M-S-f", do
sendMessage ToggleStruts
sendMessage ToggleGaps
toggleWindowSpacingEnabled
withFocused toggleBorder
refresh)
, ("M-a c" , spawn "code")
, ("M-a d" , spawnOn "cha" "discord")
, ("M-a s" , spawnOn "cha" "signal-desktop")
, ("M-a k" , spawn "virt-manager")
, ("M-a m" , spawn "mumble")
, ("M-a v" , spawn "virtualbox")
-- file managers
, ("M-f k", spawn ("kitty" ++ " -e ranger"))
, ("M-f d", spawn "dolphin")
-- cycle keyboards
-- dmenu
, ("M-S-<Return>", spawn "dmenu_run")
, ("M-p a", spawn "dmapimg")
, ("M-<Insert>", spawn "dmpsbm")
, ("M-S-<Insert>", spawn "dmpsclip")
, ("M-p c", spawn "dmclip")
, ("M-p d", spawn "dmdsktp")
, ("M-p f", spawn "dmfm")
, ("M-p g", spawn "passgen")
, ("M-p h", spawn "dmhelp")
, ("M-p l", spawn "dmlang")
, ("M-p m", spawn "passmenu")
-- , ("M-p S-m", spawn "passmenu --type")
, ("M-p p", spawn "dmpdf")
, ("M-p o", spawn "dmpower")
, ("M-p v", spawn "dmvid")
-- Gaming
, ("M-g s", spawnOn "gam" "steam")
, ("M-g m", spawnOn "gam" "multimc -l 1.8.9")
]
|