-
Notifications
You must be signed in to change notification settings - Fork 0
/
xmonad_favorite.hs
1087 lines (867 loc) · 42 KB
/
xmonad_favorite.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
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
-- xmonad config used by Malcolm MD
-- https://github.com/randomthought/xmonad-config
import System.IO
import System.Exit
-- import System.Taffybar.Hooks.PagerHints (pagerHints)
import qualified Data.List as L
import XMonad
import XMonad.Actions.Navigation2D
import XMonad.Actions.UpdatePointer
import XMonad.Actions.Minimize
import XMonad.Actions.GridSelect
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.ManageHelpers
import XMonad.Hooks.SetWMName
import XMonad.Hooks.EwmhDesktops (ewmh)
import XMonad.Hooks.Minimize
import XMonad.Layout.Gaps
import XMonad.Layout.Spiral
import XMonad.Layout.Fullscreen
import XMonad.Layout.BinarySpacePartition as BSP
import XMonad.Layout.NoBorders
import XMonad.Layout.Tabbed
import XMonad.Layout.ThreeColumns
import XMonad.Layout.Spacing
import XMonad.Layout.MultiToggle
import XMonad.Layout.MultiToggle.Instances
import XMonad.Layout.NoFrillsDecoration
import XMonad.Layout.Renamed
import XMonad.Layout.Simplest
import XMonad.Layout.SubLayouts
import XMonad.Layout.WindowNavigation
import XMonad.Layout.ZoomRow
import XMonad.Layout.Minimize
import XMonad.Layout.SimplestFloat
import XMonad.Layout.LayoutModifier
import XMonad.Layout.LimitWindows (limitWindows, increaseLimit, decreaseLimit)
import XMonad.Layout.Accordion
-- import XMonad.Layout.Tabbed (Direction2D (D, L, R, U), Theme (..), addTabs,shrinkText)
import XMonad.Layout.ResizableTile
import XMonad.Layout.NoBorders ( noBorders, smartBorders)
import XMonad.Layout.GridVariants (Grid(Grid))
import XMonad.Layout.Magnifier (magnifier)
import XMonad.Layout.IndependentScreens
import qualified XMonad.StackSet as StackSet
import XMonad.Layout.IndependentScreens (VirtualWorkspace)
import qualified XMonad.Util.NamedScratchpad as NamedScratchpad
import qualified XMonad.Actions.CycleWS as CycleWS
import qualified XMonad.Layout.Gaps as Gaps
import qualified XMonad.Layout.PerScreen as PerScreen
import qualified XMonad.Layout.IndependentScreens as IndependentScreens
import qualified Data.Bits as Bits
import XMonad.Util.NamedScratchpad
import XMonad.Util.Cursor
import XMonad.Util.NamedScratchpad (namedScratchpadFilterOutWorkspacePP)
import Graphics.X11.ExtraTypes.XF86
import qualified XMonad.StackSet as W
import qualified Data.Map as M
import XMonad.Prompt.Input
import XMonad.Hooks.ManageHelpers
import XMonad.Hooks.FadeInactive
import XMonad.Hooks.DynamicLog -- statusbar
import XMonad.Hooks.EwmhDesktops (ewmh) -- fullscreenEventHook fixes chrome fullscreen
import XMonad.Hooks.ManageDocks -- dock/tray mgmt
import XMonad.Hooks.UrgencyHook -- window alert bells
import XMonad.Hooks.SetWMName
import XMonad.ManageHook
import Graphics.X11.Xlib
import XMonad.Util.Run
-- import XMonad.Util.EZConfig -- append key/mouse bindings
import XMonad.Util.Run(spawnPipe) -- spawnPipe and hPutStrLn
import XMonad.Util.Cursor
import XMonad.Util.XSelection
import XMonad.Util.XUtils
import XMonad.Util.EZConfig(additionalKeys)
import Graphics.X11.ExtraTypes.XF86
import XMonad.Config.Desktop
import XMonad.Actions.DynamicWorkspaces
import XMonad.Actions.CycleWindows -- classic alt-tab
import XMonad.Actions.CycleWS -- cycle thru WS', toggle last WS
import XMonad.Actions.DwmPromote -- swap master like dwm
-- import XMonad.Actions.Volume
import XMonad.Hooks.FadeInactive
import XMonad.Hooks.UrgencyHook -- window alert bells
import qualified Data.Map as M
import qualified XMonad.StackSet as W
toggleFloat :: Window -> X ()
toggleFloat w =
windows
( \s ->
if M.member w (W.floating s)
then W.sink w s
else (W.float w (W.RationalRect (1 / 3) (1 / 4) (1 / 2) (1 / 2)) s)
)
----------------------------mupdf--------------------------------------------
-- Terminimport XMonad.Hooks.EwmhDesktopsal
-- The preferred terminal program, which is used in a binding below and by
-- certain contrib modules.
--
-- myTerminal = "termite"
myTerminal = "st"
-- The command to lock the screen or show the screensaver.
myScreensaver = "dm-tool switch-to-greeter"
-- The command to take a selective screenshot, where you select
-- what you'd like to capture on the screen.
mySelectScreenshot = "select-screenshot"
-- The command to take a fullscreen screenshot.
myScreenshot = "xfce4-screenshooter"
-- The command to use as a launcher, to launch commands that don't have
-- preset keybindings.
myLauncher = "rofi -show"
------------------------------------------------------------------------
-- Workspaces
-- The default number of workspaces (virtual screens) and their names.
-- -- withScreens <number of screens> <list of workspace names>
-- myWorkspaces = IndependentScreens.withScreens 2 ["1:Browser","2:Code","3:Term","4:File","5:Graph","6:Au/Video"] ++ map show [7..8]
-- myWorkspaces = ["1:Brows","2:Code","3:Term","4:File","5:Editor","6:Graph","7:Video","8:Music","9:Game"] ++ map show [9]
myWorkspaces = ["1:Brows","2:Editor","3:CodeIDE","4:Term","5:C/C++","6:Python","7:MatLab","8:VBox","9:Remote"]
-- -- Set number of screens
-- numScreens = 2
-- virtualWorkspaces = ["i", "ii", "iii", "iv", "v", "vi", "vii", "viii", "ix", "x"]
-- -- use IndependentScreens to create per-screen workspaces
-- myWorkspaces = withScreens numScreens virtualWorkspaces
------------------------------------------------------------------------
-- 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.
--
myScratchPads :: [NamedScratchpad]
myScratchPads = [ NS "terminal" spawnTerm findTerm manageTerm
, NS "mocp" spawnMocp findMocp manageMocp
, NS "calculator" spawnCalc findCalc manageCalc
]
where
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 mocp -e mocp"
findMocp = title =? "mocp"
manageMocp = customFloating $ W.RationalRect l t w h
where
h = 0.9
w = 0.9
t = 0.95 -h
l = 0.95 -w
spawnCalc = "qalculate-gtk"
findCalc = className =? "Qalculate-gtk"
manageCalc = customFloating $ W.RationalRect l t w h
where
h = 0.5
w = 0.4
t = 0.75 -h
l = 0.70 -w
myManageHook = composeAll
[
className =? "Google-chrome" --> doShift "2:web"
, resource =? "desktop_window" --> doIgnore
, className =? "Galculator" --> doCenterFloat
, className =? "Steam" --> doCenterFloat
, className =? "Gimp" --> doCenterFloat
, resource =? "gpicview" --> doCenterFloat
, className =? "MPlayer" --> doCenterFloat
, className =? "Pavucontrol" --> doCenterFloat
, className =? "Mate-power-preferences" --> doCenterFloat
, className =? "Xfce4-power-manager-settings" --> doCenterFloat
, className =? "VirtualBox" --> doShift "4:vm"
, className =? "Xchat" --> doShift "5:media"
, className =? "stalonetray" --> doIgnore
, isFullscreen --> (doF W.focusDown <+> doFullFloat)
-- , isFullscreen --> doFullFloat
]<+> namedScratchpadManageHook myScratchPads
------------------------------------------------------------------------
-- 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.
-- Colors for text and backgrounds of each tab when in "Tabbed" layout.
tabConfig = defaultTheme {
-- fontName = "xft:CaskaydiaCove Nerd Font Mono:style=SemiLight:pixelsize=12",
-- fontName = "xft:CaskaydiaCove Nerd Font Mono SemiLight-14",
-- fontName = "xft:CaskaydiaCove Nerd Font Mono-14",
-- fontName = "xft:WenQuanYi Micro Hei-15",
fontName = "xft:WenQuanYi Micro Hei:style=Regular:size=12",
activeBorderColor = "#7C7C7C",
activeTextColor = "#00ff00",
activeColor = "#7C7C7C",
inactiveBorderColor = "#000000",
inactiveTextColor = "#EEEEEE",
inactiveColor = "#000000"
}
outerGaps = 2
myGaps = gaps [(U, outerGaps), (R, outerGaps), (L, outerGaps), (D, outerGaps)]
addSpace = renamed [CutWordsLeft 2] . spacing gap
tabBSP = avoidStruts
$ minimize
$ renamed [Replace "Tabbed"]
$ addTopBar
$ myGaps
$ tabbed shrinkText myTabTheme
myBSP = renamed [CutWordsLeft 1]
$ addTopBar
$ windowNavigation
$ renamed [Replace "BSP"]
$ addTabs shrinkText myTabTheme
$ subLayout [] Simplest
$ myGaps
$ addSpace (BSP.emptyBSP)
tabs = renamed [Replace "Tabbed"]
$ tabbed shrinkText tabConfig
tabTheme = def {
-- fontName = "xft:CaskaydiaCove Nerd Font Mono:style=SemiLight:pixelsize=12",
-- fontName = "xft:CaskaydiaCove Nerd Font Mono SemiLight-14",
-- fontName = "xft:CaskaydiaCove Nerd Font Mono-14",
-- fontName = "xft:WenQuanYi Micro Hei-15",
fontName = "xft:WenQuanYi Micro Hei:style=Regular:size=12",
activeColor = "#4D4D4D",
inactiveColor = "#282A36",
activeBorderColor = myFocusedBorderColor,
inactiveBorderColor = "#282A36"
}
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
-- 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
-- Layouts
tallA = renamed [Replace "TallA"]
$ minimize
$ addTabs shrinkText myTabTheme
$ subLayout [] (Simplest)
$ mySpacing 2
$ ResizableTall 1 (3/100) (1/2) []
tallB = renamed [Replace "TallB"]
$ minimize
-- $ addTopBar
$ smartBorders
$ windowNavigation
$ addTabs shrinkText myTabTheme
$ subLayout [] (smartBorders Simplest)
$ limitWindows 12
$ mySpacing 2
$ ResizableTall 1 (3/100) (1/2) []
grid = renamed [Replace "grid"]
$ minimize
$ smartBorders
$ windowNavigation
$ addTabs shrinkText myTabTheme
$ subLayout [] (smartBorders Simplest)
$ limitWindows 12
$ mySpacing 2
$ mkToggle (single MIRROR)
$ Grid (16/10)
spirals = renamed [Replace "Spirals"]
$ minimize
$ smartBorders
$ windowNavigation
$ addTabs shrinkText myTabTheme
$ subLayout [] (smartBorders Simplest)
$ mySpacing' 1
$ spiral (6/7)
floatsA = renamed [Replace "Float"]
$ addTopBar
$ simplestFloat
--floatsB = renamed [Replace "floats"]
-- $ smartBorders
-- $ limitWindows 20 simplestFloat
magnify = renamed [Replace "magnify"]
$ minimize
$ smartBorders
$ windowNavigation
$ addTabs shrinkText myTabTheme
$ subLayout [] (smartBorders Simplest)
$ magnifier
$ limitWindows 12
$ mySpacing 2
$ ResizableTall 1 (3/100) (1/2) []
monocle = renamed [Replace "FullScreen"]
$ minimize
$ smartBorders
$ windowNavigation
$ addTabs shrinkText myTabTheme
$ subLayout [] (smartBorders Simplest)
$ limitWindows 20 Full
threeCol = renamed [Replace "threeCol"]
$ minimize
$ smartBorders
$ windowNavigation
$ addTabs shrinkText myTabTheme
$ subLayout [] (smartBorders Simplest)
$ limitWindows 7
$ ThreeCol 1 (3/100) (1/2)
threeRow = renamed [Replace "threeRow"]
$ minimize
$ smartBorders
$ windowNavigation
$ addTabs shrinkText myTabTheme
$ subLayout [] (smartBorders Simplest)
$ limitWindows 7
-- Mirror takes a layout and rotates it by 90 degrees.
-- So we are applying Mirror to the ThreeCol layout.
$ Mirror
$ ThreeCol 1 (3/100) (1/2)
accordionTall = renamed [Replace "Tall Accordion"]
$ minimize
-- $ addTopBar
$ mySpacing 5
$ addTabs shrinkText myTabTheme
$ Accordion
accordionWide = renamed [Replace "Wide Accordion"]
$ minimize
-- $ addTopBar
$ mySpacing 5
$ addTabs shrinkText myTabTheme
$ Mirror Accordion
----------------------------------------------------------------------------------
layouts = avoidStruts (
-- Tall 1 (3/100) (1/2) |||
-- tallA |||
tabs |||
tabBSP |||
tallB |||
myBSP |||
monocle |||
magnify
-- threeCol |||
-- threeRow |||
-- grid |||
-- spirals |||
-- Full |||
-- accordionWide |||
-- floatsB
-- ThreeColMid 1 (3/100) (1/2)
-- spiral (6/7) |||
-- Mirror (Tall 1 (3/100) (1/2) |||
-- tabbed shrinkText tabConfig |||
-- accordionTall |||
)
myLayout = smartBorders
$ mkToggle (NOBORDERS ?? FULL ?? EOT)
$ layouts
myNav2DConf = def
{ defaultTiledNavigation = centerNavigation
, floatNavigation = centerNavigation
, screenNavigation = lineNavigation
, layoutNavigation = [("Full", centerNavigation)
-- line/center same results ,("Tabs", lineNavigation)
-- ,("Tabs", centerNavigation)
]
, unmappedWindowRect = [("Full", singleWindowRect)
-- works but breaks tab deco ,("Tabs", singleWindowRect)
-- doesn't work but deco ok ,("Tabs", fullScreenRect)
]
}
------------------------------------------------------------------------
-- Colors and borders
-- Color of current window title in xmobar.
xmobarTitleColor = "#C678DD"
-- Color of current workspace in xmobar.
xmobarCurrentWorkspaceColor = "#51AFEF"
-- Width of the window border in pixels.
myBorderWidth = 1
myNormalBorderColor = "#000000"
myFocusedBorderColor = active
base03 = "#002b36"
base02 = "#073642"
base01 = "#586e75"
base00 = "#657b83"
base0 = "#839496"
base1 = "#93a1a1"
base2 = "#eee8d5"
base3 = "#fdf6e3"
yellow = "#b58900"
orange = "#cb4b16"
red = "#dc322f"
magenta = "#d33682"
violet = "#6c71c4"
blue = "#268bd2"
cyan = "#2aa198"
green = "#859900"
-- sizes
gap = 4
topbar = 7
border = 1
prompt = 20
status = 20
active = blue
activeWarn = red
inactive = base02
focusColor = blue
unfocusColor = base02
-- myFont = "-*-Zekton-medium-*-*-*-*-160-*-*-*-*-*-*"
-- myBigFont = "-*-Zekton-medium-*-*-*-*-240-*-*-*-*-*-*"
-- myFont = "xft:Zekton:size=9:bold:antialias=true"
-- myFont = "xft:CaskaydiaCove Nerd Font Mono:pixelsize=16"
myFont = "xft:WenQuanYi Micro Hei:style=Regular:size=12"
myBigFont = "xft:Zekton:size=9:bold:antialias=true"
myWideFont = "xft:Eurostar Black Extended:"
++ "style=Regular:pixelsize=180:hinting=true"
-- this is a "fake title" used as a highlight bar in lieu of full borders
-- (I find this a cleaner and less visually intrusive solution)
topBarTheme = def
{
fontName = myFont
, inactiveBorderColor = base03
, inactiveColor = base03
, inactiveTextColor = base03
, activeBorderColor = active
, activeColor = active
, activeTextColor = active
, urgentBorderColor = red
, urgentTextColor = yellow
, decoHeight = topbar
}
addTopBar = noFrillsDeco shrinkText topBarTheme
myTabTheme = def
{ fontName = myFont
, activeColor = active
, inactiveColor = base02
, activeBorderColor = active
, inactiveBorderColor = base02
, activeTextColor = base03
, inactiveTextColor = base00
}
------------------------------------------------------------------------
-- Key bindings
--
-- 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 = mod4Mask
altMask = mod1Mask
myKeys conf@(XConfig {XMonad.modMask = modMask}) = M.fromList $
----------------------------------------------------------------------
-- Toggle current focus window to fullscreen,
[
-- ================================================================================================================
-- ======================= 窗口布局相关快捷键=========================
-- ================================================================================================================
-- Cycle through the available layout algorithms.遍历各种窗口布局
((modMask.|. shiftMask, xK_space), sendMessage NextLayout)
-- Reset the layouts on the current workspace to default.将当前标签页窗口布局模式变为default
, ((modMask .|. controlMask, xK_space), setLayout $ XMonad.layoutHook conf)
-- Resize viewed windows to the correct size.
-- , ((modMask, xK_n), refresh)
-- Increment the number of windows in the master area.
-- 插入主窗格的堆栈,窗口竖向排列. 控制左侧主窗格中显示的窗口数
, ((modMask .|. shiftMask, xK_h), sendMessage (IncMasterN 1))
-- Decrement the number of windows in the master area.
-- 插入主窗格的堆栈,窗口竖向排列. 控制左侧主窗格中显示的窗口数
, ((modMask .|. shiftMask, xK_l), sendMessage (IncMasterN (-1)))
-- Push window back into tiling.将浮动窗口重新变为平铺
-- , ((modMask, xK_t), withFocused $ windows . W.sink)
, ((modMask .|. altMask, xK_space), withFocused $ windows . W.sink)
-- , ((modMask, xK_y), withFocused $ windows .toggleFloat)
, ((modMask , xK_space), withFocused toggleFloat)
-- 最大化与还原
, ((modMask, xK_f), sendMessage $ Toggle FULL)
-- 最小化与还原
, ((modMask, xK_m ), withFocused minimizeWindow)
, ((modMask .|. shiftMask, xK_m ), withLastMinimized maximizeWindowAndFocus)
-- close focused window Win + Shift + Q: 杀死当前窗口
, ((modMask .|. shiftMask, xK_q), kill)
-- ================================================================================================================
-- ======================= 同一个标签页的窗口间切换, ====================
-- ================================================================================================================
-- Move focus to the next window. 在同一虚拟桌面中的窗口之间切换,包括浮动与平铺
, ((modMask, xK_k), windows W.focusDown)
-- Move focus to the previous window. 在同一虚拟桌面中的窗口之间切换,包括浮动与平铺
, ((modMask, xK_j), windows W.focusUp )
-- Move focus to the next window. 在同一虚拟桌面中的窗口之间切换,包括浮动与平铺
, ((modMask, xK_w), windows W.focusDown)
-- Move focus to the previous window. 在同一虚拟桌面中的窗口之间切换,包括浮动与平铺
, ((modMask, xK_q), windows W.focusUp )
-- Move focus to the next window. 在同一虚拟桌面中的窗口之间切换,包括浮动与平铺
, ((modMask, xK_period), windows W.focusDown)
-- Move focus to the previous window. 在同一虚拟桌面中的窗口之间切换,包括浮动与平铺
, ((modMask, xK_comma), windows W.focusUp )
-- Move focus to the master window.聚焦到主窗口
-- , ((modMask, xK_m), windows W.focusMaster )
, ((modMask .|. controlMask, xK_Return), windows W.focusMaster )
-- Swap the focused window and the master window.将当前窗口与主窗口互换,单向
, ((modMask.|. shiftMask, xK_Return), windows W.swapMaster)
-- Swap the focused window with the next window.将聚焦的窗口与相邻的窗口交换。
, ((modMask .|. shiftMask, xK_j), windows W.swapDown )
-- Swap the focused window with the previous window.将聚焦的窗口与相邻的窗口交换
, ((modMask .|. shiftMask, xK_k), windows W.swapUp )
-- ================================================================================================================
-- 窗口大小调整
-- ================================================================================================================
-- Shrink the master area.
-- TallB 模式下上下缩放
, ((modMask .|. controlMask , xK_9), sendMessage Shrink)
-- Expand the master area.
, ((modMask .|. controlMask , xK_0), sendMessage Expand)
-- Shrink and expand ratio between the secondary panes, for the ResizableTall layout
, ((modMask .|. altMask , xK_9), sendMessage MirrorShrink)
, ((modMask .|. altMask , xK_0), sendMessage MirrorExpand)
, ((modMask .|. altMask, xK_Left ), sendMessage Shrink)
, ((modMask .|. altMask, xK_Right ), sendMessage Expand)
, ((modMask .|. altMask, xK_Up ), sendMessage MirrorShrink)
, ((modMask .|. altMask, xK_Down ), sendMessage MirrorExpand)
-- modMask .|. shiftMask + 上下左右 是将当前窗口向 上下左右交换/移动
-- 最大化桌面,不是全屏当前窗口
, ((modMask , xK_p ), sendMessage ToggleStruts)
-- , ("M-S-a", sendMessage Taller)
-- , ("M-S-z", sendMessage Wider)
-- myBSP 模式下上下缩放
, ((modMask, xK_minus), sendMessage $ ExpandTowards L)
, ((modMask, xK_equal), sendMessage $ ExpandTowards R)
, ((modMask .|. shiftMask , xK_minus ), sendMessage $ ExpandTowards U)
, ((modMask .|. shiftMask, xK_equal ), sendMessage $ ExpandTowards D)
, ((modMask .|. controlMask, xK_Left ), sendMessage $ ExpandTowards L)
, ((modMask .|. controlMask, xK_Right ), sendMessage $ ExpandTowards R)
, ((modMask .|. controlMask, xK_Up ), sendMessage $ ExpandTowards U)
, ((modMask .|. controlMask, xK_Down ), sendMessage $ ExpandTowards D)
-- =============================================================================================================
-- ====== 桌面间切换以及窗口在桌面间移动,和i3很类似,但是有点不同在于:
-- i3中左右移动窗口到前后的桌面仅限于存在窗口的桌面,但是xmonad左右移动窗口到左右桌面,桌面可以是不存在窗口的桌面,只按序号来
-- =============================================================================================================
-- 聚焦于下一个桌面(标签页,worspace)
-- , ((modm, xK_Page_Down), nextWS)
, ((modMask, xK_quoteright), nextWS)
-- 聚焦于上一个桌面(标签页,worspace)
-- , ((modMask, xK_Page_Up), prevWS)
, ((modMask, xK_semicolon), prevWS)
-- 聚焦于下一个桌面(标签页,worspace)
, ((modMask, xK_s), nextWS)
-- 聚焦于上一个桌面(标签页,worspace)
, ((modMask, xK_a), prevWS)
-- 聚焦于下一个桌面(标签页,worspace)
, ((modMask .|. shiftMask, xK_period), nextWS)
-- 聚焦于上一个桌面(标签页,worspace)
, ((modMask .|. shiftMask, xK_comma), prevWS)
-- Mod4 + b 快速切换到上一个聚焦的标签页(桌面)
, ((modMask, xK_b), toggleWS)
, ((modMask, xK_grave), toggleWS)
-- 将当前窗口移动到下一个桌面,但仍然聚焦在当前桌面,桌面按照序号排列,无论有无窗口
, ((modMask .|. shiftMask, xK_quoteright ), shiftToNext)
-- 将当前窗口移动到上一个桌面,桌面按照序号排列,无论有无窗口
, ((modMask .|. shiftMask, xK_semicolon), shiftToPrev)
-- 将当前窗口移动到下一个桌面,聚焦到下一个桌面
, ((modMask .|. controlMask, xK_quoteright), shiftToNext >> nextWS)
-- 将当前窗口移动到下一个桌面,聚焦到下一个桌面
, ((modMask .|. controlMask, xK_semicolon), shiftToPrev >> prevWS)
-- =============================================================================================================
-- ====== 显示器间切换以及窗口在显示器间移动
-- 两个显示器公用所有的桌面,也就是桌面1在显示器1显示就不会在显示器2显示
-- =============================================================================================================
-- 切换到上/下一个显示器
, ((modMask, xK_bracketright), nextScreen)
, ((modMask, xK_Escape), nextScreen)
, ((modMask, xK_bracketleft), prevScreen)
-- , ((modMask .|. controlMask, xK_period), nextScreen)
-- , ((modMask .|. controlMask, xK_comma), prevScreen)
, ((modMask .|. controlMask, xK_k), nextScreen)
, ((modMask .|. controlMask, xK_j), prevScreen)
-- , ((modMask, xK_s), nextScreen)
-- , ((modMask, xK_a), prevScreen)
-- 将当前窗口移动到下一个显示器,但仍然聚焦与当前显示器
, ((modMask .|. shiftMask, xK_bracketright), shiftNextScreen)
-- 将当前窗口移动到上一个显示器,但仍然聚焦与当前显示器
, ((modMask .|. shiftMask, xK_bracketleft), shiftPrevScreen)
-- 将当前窗口移动到下一个显示器,聚焦于下一个显示器
, ((modMask .|. controlMask, xK_bracketright), shiftNextScreen >> nextScreen)
-- 将当前窗口移动到上一个显示器,聚焦于上一个显示器
, ((modMask .|. controlMask, xK_bracketleft), shiftPrevScreen >> prevScreen)
-- Mirror toggle
, ((modMask, xK_x) , sendMessage $ Toggle MIRROR)
-- ==========================================================================================
-- APP 快捷键
-- ==========================================================================================
-- Custom key bindings
--
-- Start a terminal. Terminal to start is specified by myTerminal variable.
, ((modMask , xK_Return),
spawn $ XMonad.terminal conf)
-- Lock the screen using command specified by myScreensaver.
-- 锁屏
, ((modMask .|. controlMask, xK_b ), spawn "betterlockscreen -l")
, ((modMask .|. controlMask, xK_x ), spawn "xscreensaver-command -lock")
, ((modMask .|. controlMask, xK_s ), spawn "slock")
-- Spawn the launcher using command specified by myLauncher.
-- Use this to launch programs without a key binding.
-- , ((modMask, xK_p), spawn myLauncher)
-- 启动 dmenu,用于启动各种命令
, ((modMask, xK_d ), spawn "dmenu_run")
, ((modMask, xK_x ), spawn "xterm")
-- 启动 rofi,用于启动各种命令
, ((modMask, xK_r), spawn "rofi -show combi" )
, ((modMask .|. controlMask, xK_t), spawn "bash ~/.xmonad/script/touchpad.sh" )
-- change wallpapaer
,((modMask .|. shiftMask, xK_b ), spawn "feh --recursive --randomize --bg-fill $(xdg-user-dir PICTURES)'/Wallpapers/'" )
-- launch google-chrome-stale
, ((modMask , xK_g ), spawn "google-chrome-stable")
-- launch typora
, ((modMask , xK_t ), spawn "typora")
-- launch nautilus
, ((modMask , xK_n ), spawn "nautilus")
-- launch thunar
, ((modMask .|. shiftMask, xK_t ), spawn "thunar")
-- Take a selective screenshot using the command specified by mySelectScreenshot.
-- , ((modMask .|. shiftMask, xK_p), spawn mySelectScreenshot)
-- Take a full screenshot using the command specified by myScreenshot.
-- , ((modMask .|. controlMask .|. shiftMask, xK_p), spawn myScreenshot)
-- screenshot screen 截图
, ((0 , xK_Print), spawn "scrot -cd 3 $(xdg-user-dir PICTURES)/'Scrot_%Y-%m-%d_%H:%M:%S_$wx$h.png' -e 'xclip -selection clipboard -target image/png -i $f; viewnior $f';exec notify-send 'Scrot截图 截取全屏 无GUI 保存指定路径 延迟3s 复制到剪切板 打开查看'")
, ((modMask , xK_Print), spawn "scrot $(xdg-user-dir PICTURES)/'Scrot_%Y-%m-%d_%H:%M:%S_$wx$h.png' -e 'xclip -selection clipboard -target image/png -i $f; viewnior $f';exec notify-send 'Scrot截图 截取全屏 无GUI 保存指定路径 不延迟 复制到剪切板 打开查看'")
-- screenshot window or area 截图
, ((modMask .|. shiftMask, xK_Print), spawn "deepin-screenshot ;exec notify-send '深度截图'")
, ((shiftMask, xK_Print), spawn "flameshot gui -p $(xdg-user-dir PICTURES) -d 2000; exec notify-send '火焰截图 无延时 自己选择截图区域 保存在~/图片'")
, ((controlMask, xK_Print), spawn "flameshot full -c -p $(xdg-user-dir PICTURES) -d 2000; exec notify-send '火焰截图 捕获全屏(无GUI)并保存到剪贴板和路径~/图片 延迟2秒'")
-- ==========================================================================================
-- ================= 音量控制
-- ==========================================================================================
-- Mute volume.
, ((0, xF86XK_AudioMute), spawn "amixer -D pulse set Master 1+ toggle")
-- Decrease volume.
, ((0, xF86XK_AudioLowerVolume), spawn "amixer -q set Master 5%-")
-- Increase volume.
, ((0, xF86XK_AudioRaiseVolume), spawn "amixer -q set Master 5%+")
-- Mute volume.
, ((0, xF86XK_AudioMute), spawn "pactl set-sink-mute @DEFAULT_SINK@ toggle")
-- Decrease volume.
, ((0, xF86XK_AudioLowerVolume), spawn "pactl set-sink-volume @DEFAULT_SINK@ -8%")
-- Increase volume.
, ((0, xF86XK_AudioRaiseVolume), spawn "pactl set-sink-volume @DEFAULT_SINK@ +8%")
-- Decrease light.
, ((0, xF86XK_MonBrightnessUp), spawn "xbacklight -inc 5")
-- Increase light.
, ((0, xF86XK_MonBrightnessDown), spawn "xbacklight -dec 5")
-- -- 音乐播放器 controls
-- , ((0, XF86AudioPlay), spawn "playerctl play-pause")
-- , ((0, XF86AudioNext), spawn "playerctl next")
-- , ((0, XF86AudioPrev), spawn "playerctl previous")
-- 音乐播放器 controls
-- , ((0, XF86AudioPlay), spawn "mpc toggle")
-- , ((0, XF86AudioNext), spawn "mpc next")
-- , ((0, XF86AudioPrev), spawn "mpc prev")
-- Mute volume.
, ((modMask .|. altMask, xK_BackSpace), spawn "amixer -D pulse set Master 1+ toggle")
-- Decrease volume.
, ((modMask .|. altMask, xK_minus), spawn "amixer -q set Master 5%-")
-- Increase volume.
, ((modMask .|. altMask, xK_equal), spawn "amixer -q set Master 5%+")
-- Mute volume.
, ((modMask .|. controlMask, xK_BackSpace), spawn "pactl set-sink-mute @DEFAULT_SINK@ toggle")
-- Decrease volume.
, ((modMask .|. controlMask, xK_minus), spawn "pactl set-sink-volume @DEFAULT_SINK@ -8%")
-- Increase volume.
, ((modMask .|. controlMask, xK_equal), spawn "pactl set-sink-volume @DEFAULT_SINK@ +8%")
-- Toggle the status bar gap.
-- TODO: update this binding with avoidStruts, ((modMask, xK_b),
-- Quit xmonad. 离开 xmonad
, ((modMask .|. controlMask, xK_e),
io (exitWith ExitSuccess))
-- Restart xmonad.重启 xmonad,用于改为配置之后使其生效
, ((modMask .|. controlMask, xK_r), restart "xmonad" True)
]
++
[
-- workspaces are distinct per physical screen
-- a "windowSet" is a set of windows per virtual screen
-- onCurrentScreen takes a function that operates on a virtual workspace and window set and returns a function that
-- operates on a physical workspace and window set
-- $ avoids parantheses - gives precendence to function on the right
-- . chains functions
-- see: https://stackoverflow.com/questions/940382/what-is-the-difference-between-dot-and-dollar-sign
-- StackSet.view switches to screen
-- StackSet.shift moves content to another screen
--
-- This is a list comprehension that takes each windowSet (set of windows per virtual screen), and maps a view and shift key binding
-- that operates on the appropriate physical screen
((modifierKey Bits..|. myModMask, numberKey), XMonad.windows $ IndependentScreens.onCurrentScreen screenOperation windowSet)
| (windowSet, numberKey) <- zip (IndependentScreens.workspaces' defaults) [XMonad.xK_1 .. XMonad.xK_9]
, (screenOperation, modifierKey) <- [(StackSet.view, 0), (StackSet.shift, XMonad.shiftMask)]
] ++
-- mod-[1..9], Switch to workspace N
-- mod-shift-[1..9], Move client to workspace N
[((m .|. modMask, 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 .|. modMask, key), screenWorkspace sc >>= flip whenJust (windows . f))
| (key, sc) <- zip [xK_F6, xK_F7, xK_F8] [0..]
, (f, m) <- [(W.view, 0), (W.shift, shiftMask)]]
++
-- Bindings for manage sub tabs in layouts please checkout the link below for reference
-- https://hackage.haskell.org/package/xmonad-contrib-0.13/docs/XMonad-Layout-SubLayouts.html
[
-- Tab current focused window with the window to the left
((modMask .|. altMask, xK_h), sendMessage $ pullGroup L)
-- Tab current focused window with the window to the right
, ((modMask .|. altMask, xK_l), sendMessage $ pullGroup R)
-- Tab current focused window with the window above
, ((modMask .|. altMask, xK_k), sendMessage $ pullGroup U)
-- Tab current focused window with the window below
, ((modMask .|. altMask, xK_j), sendMessage $ pullGroup D)
-- Tab all windows in the current workspace with current window as the focus
, ((modMask .|. altMask, xK_m), withFocused (sendMessage . MergeAll))
-- Group the current tabbed windows
, ((modMask .|. altMask, xK_u), withFocused (sendMessage . UnMerge))
-- Toggle through tabes from the right
, ((modMask, xK_Tab), onGroup W.focusDown')
-- , ((modMask, xK_grave), onGroup W.focusDown')
]
++
-- Some bindings for BinarySpacePartition
-- https://github.com/benweitzman/BinarySpacePartition
[
-- myBSP 模式下上下缩放
((modMask .|. controlMask .|. shiftMask, xK_Right ), sendMessage $ ShrinkFrom R)
, ((modMask .|. controlMask .|. shiftMask, xK_Left ), sendMessage $ ShrinkFrom L)
, ((modMask .|. controlMask .|. shiftMask, xK_Down ), sendMessage $ ShrinkFrom D)
, ((modMask .|. controlMask .|. shiftMask, xK_Up ), sendMessage $ ShrinkFrom U)
, ((modMask .|. shiftMask, xK_r ), sendMessage BSP.Rotate)
, ((modMask .|. shiftMask, xK_s ), sendMessage BSP.Swap)
-- , ((modMask, xK_n ), sendMessage BSP.FocusParent)
-- , ((modMask .|. controlMask, xK_n ), sendMessage BSP.SelectNode)
-- , ((modMask .|. shiftMask, xK_n ), sendMessage BSP.MoveNode)
]
------------------------------------------------------------------------
-- Mouse bindings
--
-- Focus rules
-- True if your focus should follow your mouse cursor.
myFocusFollowsMouse :: Bool
myFocusFollowsMouse = True
myMouseBindings (XConfig {XMonad.modMask = modMask}) = M.fromList $
[
-- mod+鼠标左键 将当前窗口变为浮动窗口且移动
-- mod-button1, Set the window to floating mode and move by dragging
((modMask, button1),
(\w -> focus w >> mouseMoveWindow w))
-- mod-button2, Raise the window to the top of the stack
, ((modMask, button2),
(\w -> focus w >> windows W.swapMaster))
-- mod-button3, Set the window to floating mode and resize by dragging
-- mod+鼠标右键 缩放窗口
, ((modMask, button3),
(\w -> focus w >> mouseResizeWindow w))
-- you may also bind events to the mouse scroll wheel (button4 and button5)
, ((mod4Mask, button4), (\w -> windows W.focusUp))
, ((mod4Mask, button5), (\w -> windows W.focusDown))
]
------------------------------------------------------------------------
-- Status bars and logging
-- Perform an arbitrary action on each internal state change or X event.
-- See the 'DynamicLog' extension for examples.
--
-- To emulate dwm's status bar
--
-- > logHook = dynamicLogDzen
--
------------------------------------------------------------------------
-- 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 = do
setWMName "LG3D"
spawn "bash ~/.xmonad/autostart_cjj.sh"
setDefaultCursor xC_left_ptr
------------------------------------------------------------------------
windowCount :: X (Maybe String)
windowCount = gets $ Just . show . length . W.integrate' . W.stack . W.workspace . W.current . windowset
------------------------------------------------------------------------