-
Notifications
You must be signed in to change notification settings - Fork 0
/
xmonad.hs
392 lines (305 loc) · 15 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
389
390
391
392
import System.IO
import System.Exit
import XMonad
import XMonad.Hooks.SetWMName
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.EwmhDesktops
import XMonad.Hooks.ManageHelpers(doFullFloat, doCenterFloat, isFullscreen, isDialog)
import XMonad.Config.Desktop
import XMonad.Config.Azerty
import XMonad.Util.Run(spawnPipe)
import XMonad.Actions.SpawnOn
import XMonad.Util.EZConfig (additionalKeys, additionalMouseBindings)
import XMonad.Actions.CycleWS
import XMonad.Hooks.UrgencyHook
import qualified Codec.Binary.UTF8.String as UTF8
import XMonad.Layout.Grid
import XMonad.Layout.Spacing
import XMonad.Layout.Gaps
import XMonad.Layout.ResizableTile
import XMonad.Layout.NoBorders
import XMonad.Layout.Fullscreen (fullscreenFull)
import XMonad.Layout.Cross(simpleCross)
import XMonad.Layout.Spiral(spiral)
import XMonad.Layout.ThreeColumns
import XMonad.Layout.MultiToggle
import XMonad.Layout.MultiToggle.Instances
import XMonad.Layout.IndependentScreens
import XMonad.Actions.NoBorders
import XMonad.Layout.CenteredMaster(centerMaster)
import Graphics.X11.ExtraTypes.XF86
import qualified XMonad.StackSet as W
import qualified Data.Map as M
import qualified Data.ByteString as B
import Control.Monad (liftM2)
import qualified DBus as D
import qualified DBus.Client as D
myStartupHook = do
spawn "$HOME/.xmonad/scripts/autostart.sh"
setWMName "LG3D"
-- colours
normBord = "#d79921"
focdBord = "#689d6a"
fore = "#DEE3E0"
back = "#282c34"
winType = "#c678dd"
--mod4Mask= super key
--mod1Mask= alt key
--controlMask= ctrl key
--shiftMask= shift key
myModMask = mod4Mask
encodeCChar = map fromIntegral . B.unpack
myFocusFollowsMouse = True
myBorderWidth = 2
myWorkspaces = ["1","2","3","4","5","6","7","8","9","10"]
--myWorkspaces = ["I","II","III","IV","V","VI","VII","VIII","IX","X"]
myBaseConfig = desktopConfig
-- window manipjlations
myManageHook = composeAll . concat $
[ [isDialog --> doCenterFloat]
, [className =? c --> doCenterFloat | c <- myCFloats]
, [title =? t --> doFloat | t <- myTFloats]
, [resource =? r --> doFloat | r <- myRFloats]
, [resource =? i --> doIgnore | i <- myIgnores]
-- , [(className =? x <||> title =? x <||> resource =? x) --> doShiftAndGo "\61612" | x <- my1Shifts]
-- , [(className =? x <||> title =? x <||> resource =? x) --> doShiftAndGo "\61899" | x <- my2Shifts]
-- , [(className =? x <||> title =? x <||> resource =? x) --> doShiftAndGo "\61947" | x <- my3Shifts]
-- , [(className =? x <||> title =? x <||> resource =? x) --> doShiftAndGo "\61635" | x <- my4Shifts]
-- , [(className =? x <||> title =? x <||> resource =? x) --> doShiftAndGo "\61502" | x <- my5Shifts]
-- , [(className =? x <||> title =? x <||> resource =? x) --> doShiftAndGo "\61501" | x <- my6Shifts]
-- , [(className =? x <||> title =? x <||> resource =? x) --> doShiftAndGo "\61705" | x <- my7Shifts]
-- , [(className =? x <||> title =? x <||> resource =? x) --> doShiftAndGo "\61564" | x <- my8Shifts]
-- , [(className =? x <||> title =? x <||> resource =? x) --> doShiftAndGo "\62150" | x <- my9Shifts]
-- , [(className =? x <||> title =? x <||> resource =? x) --> doShiftAndGo "\61872" | x <- my10Shifts]
]
where
-- doShiftAndGo = doF . liftM2 (.) W.greedyView W.shift
myCFloats = ["Arandr", "Arcolinux-calamares-tool.py", "Arcolinux-tweak-tool.py", "Arcolinux-welcome-app.py", "Galculator", "feh", "Xfce4-terminal"]
myTFloats = ["Downloads", "Save As..."]
myRFloats = []
myIgnores = ["desktop_window"]
-- my1Shifts = ["Chromium", "Vivaldi-stable", "Firefox"]
-- my2Shifts = []
-- my3Shifts = ["Inkscape"]
-- my4Shifts = []
-- my5Shifts = ["Gimp", "feh"]
-- my6Shifts = ["vlc", "mpv"]
-- my7Shifts = ["Virtualbox"]
-- my8Shifts = ["Thunar"]
-- my9Shifts = []
-- my10Shifts = ["discord"]
myLayout = spacingRaw True (Border 0 5 5 5) True (Border 5 5 5 5) True $ avoidStruts $ mkToggle (NBFULL ?? NOBORDERS ?? EOT) $ tiled ||| grid ||| monocle
where
tiled = spacing 15 $ ResizableTall 1 (3/100) (1/2) []
grid = spacing 10 $ GridRatio (4/3)
monocle = smartBorders (Full)
--- tiled = Tall nmaster delta tiled_ratio
--- nmaster = 1
--- delta = 3/100
--- tiled_ratio = 1/2
myMouseBindings (XConfig {XMonad.modMask = modMask}) = M.fromList $
-- mod-button1, Set the window to floating mode and move by dragging
[ ((modMask, 1), (\w -> focus w >> mouseMoveWindow w >> windows W.shiftMaster))
-- mod-button2, Raise the window to the top of the stack
, ((modMask, 2), (\w -> focus w >> windows W.shiftMaster))
-- mod-button3, Set the window to floating mode and resize by dragging
, ((modMask, 3), (\w -> focus w >> mouseResizeWindow w >> windows W.shiftMaster))
]
-- keys config
myKeys conf@(XConfig {XMonad.modMask = modMask}) = M.fromList $
----------------------------------------------------------------------
-- SUPER + FUNCTION KEYS
[ ((modMask, xK_p), spawn $ "brave" )
, ((modMask, xK_c), spawn $ "conky-toggle" )
, ((modMask, xK_f), sendMessage $ Toggle NBFULL)
, ((modMask, xK_h), spawn $ "urxvt 'htop task manager' -e htop" )
, ((modMask, xK_m), spawn $ "pragha" )
, ((modMask, xK_q), kill )
, ((modMask, xK_r), spawn $ "rofi-theme-selector" )
, ((modMask, xK_t), spawn $ "urxvt" )
, ((modMask, xK_v), spawn $ "pavucontrol" )
, ((modMask, xK_y), spawn $ "polybar-msg cmd toggle" )
, ((modMask, xK_x), spawn $ "arcolinux-logout" )
, ((modMask, xK_Escape), spawn $ "xkill" )
, ((modMask, xK_Return), spawn $ "alacritty" )
, ((modMask, xK_F1), spawn $ "vivaldi-stable" )
, ((modMask, xK_F2), spawn $ "code" )
, ((modMask, xK_F3), spawn $ "inkscape" )
, ((modMask, xK_F4), spawn $ "gimp" )
, ((modMask, xK_F5), spawn $ "meld" )
, ((modMask, xK_F6), spawn $ "vlc --video-on-top" )
, ((modMask, xK_F7), spawn $ "virtualbox" )
, ((modMask, xK_F8), spawn $ "thunar" )
, ((modMask, xK_F9), spawn $ "evolution" )
, ((modMask, xK_F10), spawn $ "spotify" )
, ((modMask, xK_F11), spawn $ "rofi -theme-str 'window {width: 100%;height: 100%;}' -show drun" )
, ((modMask, xK_F12), spawn $ "rofi -show drun" )
-- FUNCTION KEYS
, ((0, xK_F12), spawn $ "xfce4-terminal --drop-down" )
-- SUPER + SHIFT KEYS
, ((modMask .|. shiftMask , xK_Return ), spawn $ "thunar")
, ((modMask .|. shiftMask , xK_d ), spawn $ "dmenu_run -i -nb '#191919' -nf '#fea63c' -sb '#fea63c' -sf '#191919' -fn 'NotoMonoRegular:bold:pixelsize=14'")
, ((modMask .|. shiftMask , xK_r ), spawn $ "xmonad --recompile && xmonad --restart")
, ((modMask .|. shiftMask , xK_q ), kill)
-- , ((modMask .|. shiftMask , xK_x ), io (exitWith ExitSuccess))
-- CONTROL + ALT KEYS
, ((controlMask .|. mod1Mask , xK_Next ), spawn $ "conky-rotate -n")
, ((controlMask .|. mod1Mask , xK_Prior ), spawn $ "conky-rotate -p")
, ((controlMask .|. mod1Mask , xK_a ), spawn $ "xfce4-appfinder")
, ((controlMask .|. mod1Mask , xK_b ), spawn $ "thunar")
, ((controlMask .|. mod1Mask , xK_c ), spawn $ "catfish")
, ((controlMask .|. mod1Mask , xK_e ), spawn $ "arcolinux-tweak-tool")
, ((controlMask .|. mod1Mask , xK_f ), spawn $ "firefox")
, ((controlMask .|. mod1Mask , xK_g ), spawn $ "chromium -no-default-browser-check")
, ((controlMask .|. mod1Mask , xK_i ), spawn $ "nitrogen")
, ((controlMask .|. mod1Mask , xK_m ), spawn $ "xfce4-settings-manager")
, ((controlMask .|. mod1Mask , xK_o ), spawn $ "$HOME/.xmonad/scripts/picom-toggle.sh")
, ((controlMask .|. mod1Mask , xK_p ), spawn $ "pamac-manager")
, ((controlMask .|. mod1Mask , xK_r ), spawn $ "rofi-theme-selector")
, ((controlMask .|. mod1Mask , xK_s ), spawn $ "spotify")
, ((controlMask .|. mod1Mask , xK_t ), spawn $ "alacritty")
, ((controlMask .|. mod1Mask , xK_u ), spawn $ "pavucontrol")
, ((controlMask .|. mod1Mask , xK_v ), spawn $ "vivaldi-stable")
, ((controlMask .|. mod1Mask , xK_w ), spawn $ "arcolinux-welcome-app")
, ((controlMask .|. mod1Mask , xK_Return ), spawn $ "alacritty")
-- ALT + ... KEYS
, ((mod1Mask, xK_f), spawn $ "variety -f" )
, ((mod1Mask, xK_n), spawn $ "variety -n" )
, ((mod1Mask, xK_p), spawn $ "variety -p" )
, ((mod1Mask, xK_r), spawn $ "xmonad --restart" )
, ((mod1Mask, xK_t), spawn $ "variety -t" )
, ((mod1Mask, xK_Up), spawn $ "variety --pause" )
, ((mod1Mask, xK_Down), spawn $ "variety --resume" )
, ((mod1Mask, xK_Left), spawn $ "variety -p" )
, ((mod1Mask, xK_Right), spawn $ "variety -n" )
, ((mod1Mask, xK_F2), spawn $ "xfce4-appfinder --collapsed" )
, ((mod1Mask, xK_F3), spawn $ "xfce4-appfinder" )
--VARIETY KEYS WITH PYWAL
, ((mod1Mask .|. shiftMask , xK_f ), spawn $ "variety -f && wal -i $(cat $HOME/.config/variety/wallpaper/wallpaper.jpg.txt)&")
, ((mod1Mask .|. shiftMask , xK_n ), spawn $ "variety -n && wal -i $(cat $HOME/.config/variety/wallpaper/wallpaper.jpg.txt)&")
, ((mod1Mask .|. shiftMask , xK_p ), spawn $ "variety -p && wal -i $(cat $HOME/.config/variety/wallpaper/wallpaper.jpg.txt)&")
, ((mod1Mask .|. shiftMask , xK_t ), spawn $ "variety -t && wal -i $(cat $HOME/.config/variety/wallpaper/wallpaper.jpg.txt)&")
, ((mod1Mask .|. shiftMask , xK_u ), spawn $ "wal -i $(cat $HOME/.config/variety/wallpaper/wallpaper.jpg.txt)&")
--CONTROL + SHIFT KEYS
, ((controlMask .|. shiftMask , xK_Escape ), spawn $ "xfce4-taskmanager")
--SCREENSHOTS
, ((0, xK_Print), spawn $ "scrot 'ArcoLinux-%Y-%m-%d-%s_screenshot_$wx$h.jpg' -e 'mv $f $$(xdg-user-dir PICTURES)'")
, ((controlMask, xK_Print), spawn $ "xfce4-screenshooter" )
, ((controlMask .|. shiftMask , xK_Print ), spawn $ "scrot -e 'xclip -selection clipboard -t image/png -i $f'")
, ((controlMask .|. modMask , xK_Print ), spawn $ "flameshot gui")
--MULTIMEDIA KEYS
-- Mute volume
, ((0, xF86XK_AudioMute), spawn $ "amixer -q set Master toggle")
-- Decrease volume
, ((0, xF86XK_AudioLowerVolume), spawn $ "amixer -q set Master 5%-")
-- Increase volume
, ((0, xF86XK_AudioRaiseVolume), spawn $ "amixer -q set Master 5%+")
-- Increase brightness
, ((0, xF86XK_MonBrightnessUp), spawn $ "xbacklight -inc 5")
-- Decrease brightness
, ((0, xF86XK_MonBrightnessDown), spawn $ "xbacklight -dec 5")
-- Alternative to increase brightness
-- Increase brightness
-- , ((0, xF86XK_MonBrightnessUp), spawn $ "brightnessctl s 5%+")
-- Decrease brightness
-- , ((0, xF86XK_MonBrightnessDown), spawn $ "brightnessctl s 5%-")
-- , ((0, xF86XK_AudioPlay), spawn $ "mpc toggle")
-- , ((0, xF86XK_AudioNext), spawn $ "mpc next")
-- , ((0, xF86XK_AudioPrev), spawn $ "mpc prev")
-- , ((0, xF86XK_AudioStop), spawn $ "mpc stop")
, ((0, xF86XK_AudioPlay), spawn $ "playerctl play-pause")
, ((0, xF86XK_AudioNext), spawn $ "playerctl next")
, ((0, xF86XK_AudioPrev), spawn $ "playerctl previous")
, ((0, xF86XK_AudioStop), spawn $ "playerctl stop")
--------------------------------------------------------------------
-- XMONAD LAYOUT KEYS
, ((modMask, xK_b), withFocused $ toggleBorder)
-- Cycle through the available layout algorithms.
, ((modMask, xK_space), sendMessage NextLayout)
--Focus selected desktop
, ((mod1Mask, xK_Tab), nextWS)
--Focus selected desktop
, ((modMask, xK_Tab), nextWS)
--Focus selected desktop
, ((controlMask .|. mod1Mask , xK_Left ), prevWS)
--Focus selected desktop
, ((controlMask .|. mod1Mask , xK_Right ), nextWS)
-- Reset the layouts on the current workspace to default.
, ((modMask .|. shiftMask, xK_space), setLayout $ XMonad.layoutHook conf)
-- Move focus to the next window.
, ((modMask, xK_j), windows W.focusDown)
-- Move focus to the previous window.
, ((modMask, xK_k), windows W.focusUp )
-- Move focus to the master window.
, ((modMask .|. shiftMask, xK_m), windows W.focusMaster )
-- Swap the focused window with the next window.
, ((modMask .|. shiftMask, xK_j), windows W.swapDown )
-- Swap the focused window with the next window.
, ((controlMask .|. modMask, xK_Down), windows W.swapDown )
-- Swap the focused window with the previous window.
, ((modMask .|. shiftMask, xK_k), windows W.swapUp )
-- Swap the focused window with the previous window.
, ((controlMask .|. modMask, xK_Up), windows W.swapUp )
-- Shrink the master area.
, ((controlMask .|. modMask , xK_h), sendMessage Shrink)
-- Expand the master area.
, ((controlMask .|. modMask , xK_l), sendMessage Expand)
-- Vertical shrink and expand
, ((controlMask .|. modMask , xK_j), sendMessage MirrorShrink)
, ((controlMask .|. modMask , xK_k), sendMessage MirrorExpand)
-- Push window back into tiling.
, ((controlMask .|. shiftMask , xK_t), withFocused $ windows . W.sink)
-- Increment the number of windows in the master area.
, ((controlMask .|. modMask, xK_Left), sendMessage (IncMasterN 1))
-- Decrement the number of windows in the master area.
, ((controlMask .|. modMask, xK_Right), sendMessage (IncMasterN (-1)))
]
++
-- mod-[1..9], Switch to workspace N
-- mod-shift-[1..9], Move client to workspace N
[((m .|. modMask, k), windows $ f i)
--Keyboard layouts
--qwerty users use this line
| (i, k) <- zip (XMonad.workspaces conf) [xK_1,xK_2,xK_3,xK_4,xK_5,xK_6,xK_7,xK_8,xK_9,xK_0]
--French Azerty users use this line
-- | (i, k) <- zip (XMonad.workspaces conf) [xK_ampersand, xK_eacute, xK_quotedbl, xK_apostrophe, xK_parenleft, xK_minus, xK_egrave, xK_underscore, xK_ccedilla , xK_agrave]
--Belgian Azerty users use this line
-- | (i, k) <- zip (XMonad.workspaces conf) [xK_ampersand, xK_eacute, xK_quotedbl, xK_apostrophe, xK_parenleft, xK_section, xK_egrave, xK_exclam, xK_ccedilla, xK_agrave]
, (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)
, (\i -> W.greedyView i . W.shift i, shiftMask)]]
++
-- ctrl-shift-{w,e,r}, Move client to screen 1, 2, or 3
-- [((m .|. controlMask, key), screenWorkspace sc >>= flip whenJust (windows . f))
-- | (key, sc) <- zip [xK_w, xK_e] [0..]
-- , (f, m) <- [(W.view, 0), (W.shift, shiftMask)]]
[((m .|. modMask, key), screenWorkspace sc >>= flip whenJust (windows . f))
| (key, sc) <- zip [xK_Left, xK_Right] [0..]
, (f, m) <- [(W.view, 0), (W.shift, shiftMask)]]
main :: IO ()
main = do
dbus <- D.connectSession
-- Request access to the DBus name
D.requestName dbus (D.busName_ "org.xmonad.Log")
[D.nameAllowReplacement, D.nameReplaceExisting, D.nameDoNotQueue]
xmonad . ewmh $
--Keyboard layouts
--qwerty users use this line
myBaseConfig
--French Azerty users use this line
--myBaseConfig { keys = azertyKeys <+> keys azertyConfig }
--Belgian Azerty users use this line
--myBaseConfig { keys = belgianKeys <+> keys belgianConfig }
{startupHook = myStartupHook
, layoutHook = gaps [(U,35), (D,5), (R,5), (L,5)] $ myLayout ||| layoutHook myBaseConfig
, manageHook = manageSpawn <+> myManageHook <+> manageHook myBaseConfig
, modMask = myModMask
, borderWidth = myBorderWidth
, handleEventHook = handleEventHook myBaseConfig <+> fullscreenEventHook
, focusFollowsMouse = myFocusFollowsMouse
, workspaces = myWorkspaces
, focusedBorderColor = focdBord
, normalBorderColor = normBord
, keys = myKeys
, mouseBindings = myMouseBindings
}