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
|
import XMonad
import qualified XMonad.StackSet as W
import XMonad.ManageHook
-- actions
import XMonad.Actions.CycleWS (moveTo, shiftTo, WSType(..), nextScreen, prevScreen)
import XMonad.Actions.CopyWindow
import XMonad.Actions.CycleWS
import XMonad.Actions.GridSelect
import XMonad.Actions.SwapWorkspaces
import XMonad.Actions.WindowBringer
import XMonad.Actions.MouseResize
-- layouts modifiers
import XMonad.Layout.Spacing
import XMonad.Layout.LayoutModifier
import XMonad.Layout.WindowNavigation as WN
import XMonad.Layout.Fullscreen
import XMonad.Layout.Renamed as R (renamed, Rename(Replace))
-- Layouts
-- import XMonad.Layout.AvoidFloats
import XMonad.Layout.BinarySpacePartition as BSP
-- import XMonad.Layout.CenteredMaster
import XMonad.Layout.Grid
import XMonad.Layout.ThreeColumns
import XMonad.Layout.TwoPane
import XMonad.Layout.Spiral
import XMonad.Layout.ResizableTile
import XMonad.Layout.Maximize
-- import XMonad.Layout.Tabbed
-- hooks
import XMonad.Hooks.SetWMName
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.DynamicLog
-- import XMonad.Hooks.FadeInactive
-- utilities
import XMonad.Util.SpawnOnce
import XMonad.Util.EZConfig (additionalKeys)
import XMonad.Util.Cursor
import XMonad.Util.Paste
import XMonad.Util.Run
import XMonad.Util.NamedScratchpad
myStartupHook :: X ()
myStartupHook = do
spawnOnce "/home/zt/.xmonad/baraction | lemonbar -b -g 500x21+800+0 -B '#171520' -F '#ffffff' -f 'Source Han Sans JP:size=10'"
spawnOnce "nitrogen --restore"
spawnOnce "picom"
spawnOnce "deadd-notification-center"
spawnOnce "firefox"
spawnOnce "weather"
-- spawnOnce "sleep 3; trayer --align center --edge top --width 20 --height 21 --expand true --distance 90 --distancefrom right --tint 0x171520 --transparent true --alpha 0 --iconspacing 8"
setWMName "Oppai"
setDefaultCursor xC_left_ptr
windowCount :: X (Maybe String)
windowCount = gets $ Just . show . length . W.integrate' . W.stack . W.workspace . W.current . windowset
-- defaults
-- myModMask :: KeyMask
myModMask = mod4Mask
altMask :: KeyMask
altMask = mod1Mask
myTerminal :: String
myTerminal = "st"
myLauncher :: String
myLauncher = "run_dmenu"
myBrowser :: String
myBrowser = "firefox"
myFileManager :: String
myFileManager = "pcmanfm"
myEmailClient :: String
myEmailClient = "thunderbird"
myEditor :: String
myEditor = "nvim"
myLockscreen :: String
myLockscreen = "betterlockscreen -l -t 'Yo, Vidhu!'"
myScreenshot :: String
myScreenshot = "scrot /zt/Screenshots/Screenshot-%Y-%d-%m--%T.png"
-- volume
myVolUp :: String
myVolUp = "pulseaudio-ctl up"
myVolDown :: String
myVolDown = "pulseaudio-ctl down"
myVolMute :: String
myVolMute = "pulseaudio-ctl mute"
-- wm variables
nBorder = "#000000" -- "#3804f4" -- "#bf00ff"
fBorder = "#6e02fc"
myBorderWidth = 1
sGap = 0 -- screen gap
wGap = 1 -- window gap
myExtraWorkspaces = [(xK_0, " 十 ")] -- , (xK_comma, " 十一 "), (xK_period, " 十二 "), (xK_slash, " 十三 ")]
myWorkspaces = [" 一 "," 二 "," 三 "," 四 "," 五 "," 六 "," 七 "," 八 ", " 九 "] ++ (map snd myExtraWorkspaces)
-- scratchpad config
myScratchpads = [
-- NS "Vysor" "Vysor.AppImage" (title =? "Vysor") defaultFloating
NS "Phone" "scrcpy" (title =? "Motorola One Power") defaultFloating,
NS "Terminal" "st -t 'TerminalScratchpad'" (title =? "TerminalScratchpad") defaultFloating,
NS "Nitrogen" "nitrogen" (title =? "Nitrogen") defaultFloating
] where role = stringProperty "WM_WINDOW_ROLE"
-- keybindings
myKeys = [
((myModMask, xK_Return), spawn (myTerminal))
, ((myModMask, xK_p), spawn (myLauncher))
, ((myModMask .|. shiftMask, xK_Return), spawn (myScreenshot))
-- , ((myModMask, xK_q), spawn (myLockscreen))
, ((mod1Mask, xK_w), kill1)
, ((mod1Mask .|. shiftMask, xK_k), kill1)
, ((myModMask, xK_a), withFocused $ windows . W.sink) -- unfloat windows
-- launch apps/execute scripts
, ((myModMask, xK_i), spawn (myBrowser))
, ((myModMask, xK_o), spawn (myFileManager))
, ((myModMask, xK_y), spawn ("gimp"))
, ((myModMask, xK_e), spawn (myEmailClient))
, ((myModMask, xK_m), spawn ("vlc"))
, ((myModMask, xK_b), spawn ("konqueror"))
-- volume
, ((altMask, xK_0), spawn (myVolMute))
, ((altMask, xK_minus), spawn (myVolDown))
, ((altMask, xK_equal), spawn (myVolUp))
-- scratchpad keybindings
, ((myModMask, xK_u), namedScratchpadAction myScratchpads "Phone")
, ((myModMask, xK_t), namedScratchpadAction myScratchpads "Terminal")
, ((myModMask, xK_w), namedScratchpadAction myScratchpads "Nitrogen")
-- view prev/next workspaces
, ((altMask, xK_h), prevWS)
, ((altMask, xK_l), nextWS)
-- move to prev/next workspaces
, ((altMask .|. shiftMask, xK_h), shiftToPrev >> prevWS)
, ((altMask .|. shiftMask, xK_l), shiftToNext >> nextWS)
-- modify gaps on runtime
, ((myModMask, xK_equal), incWindowSpacing 1)
, ((myModMask, xK_minus), decWindowSpacing 1)
, ((myModMask .|. shiftMask, xK_equal), incScreenSpacing 1)
, ((myModMask .|. shiftMask, xK_minus), decScreenSpacing 1)
-- Swap the focused window and the master window
, ((mod1Mask .|. shiftMask, xK_Return), windows W.swapMaster)
-- these keybindings are for WindowNavigation
-- and they conflict with BSP layout
-- directional navigation of windows
, ((myModMask, xK_l), sendMessage $ Go R)
, ((myModMask, xK_h), sendMessage $ Go L)
, ((myModMask, xK_k), sendMessage $ Go U)
, ((myModMask, xK_j), sendMessage $ Go D)
-- swap windows
, ((myModMask .|. shiftMask, xK_l), sendMessage $ WN.Swap R)
, ((myModMask .|. shiftMask, xK_h), sendMessage $ WN.Swap L)
, ((myModMask .|. shiftMask, xK_k), sendMessage $ WN.Swap U)
, ((myModMask .|. shiftMask, xK_j), sendMessage $ WN.Swap D)
-- cycle through windows
, ((altMask, xK_j), windows W.focusDown)
, ((altMask, xK_k), windows W.focusUp)
-- grid select
, ((myModMask, xK_g), goToSelected defaultGSConfig)
-- windowbringer
, ((myModMask, xK_b), bringMenu)
-- , ((myModMask, xK_g), gotoMenu)
-- paste x selection
, ((altMask, xK_v), pasteSelection)
-- toggle bars
, ((myModMask, xK_backslash), sendMessage ToggleStruts) -- toggle both bars
, ((myModMask, xK_bracketleft), sendMessage $ ToggleStrut D) -- toggle bottom bar
, ((myModMask, xK_bracketright), sendMessage $ ToggleStrut U) -- toggle top bar
-- BSP layout keybindings
-- resize
, ((myModMask .|. mod1Mask, xK_l ), sendMessage $ ExpandTowards R)
, ((myModMask .|. mod1Mask, xK_h ), sendMessage $ ExpandTowards L)
, ((myModMask .|. mod1Mask, xK_j ), sendMessage $ ExpandTowards D)
, ((myModMask .|. mod1Mask, xK_k ), sendMessage $ ExpandTowards U)
, ((myModMask .|. mod1Mask .|. shiftMask , xK_l ), sendMessage $ ShrinkFrom R)
, ((myModMask .|. mod1Mask .|. shiftMask , xK_h ), sendMessage $ ShrinkFrom L)
, ((myModMask .|. mod1Mask .|. shiftMask , xK_j ), sendMessage $ ShrinkFrom D)
, ((myModMask .|. mod1Mask .|. shiftMask , xK_k ), sendMessage $ ShrinkFrom U)
-- other
, ((myModMask, xK_d ), sendMessage Rotate)
, ((myModMask, xK_s ), sendMessage BSP.Swap)
-- , ((myModMask .|. shiftMask .|. controlMask , xK_j ), sendMessage $ SplitShift Prev)
-- , ((myModMask .|. shiftMask .|. controlMask , xK_k ), sendMessage $ SplitShift Next)
, ((myModMask, xK_f), withFocused (sendMessage . maximizeRestore))
] ++ [ -- for extra workspace(s)
((myModMask, key), (windows $ W.greedyView ws))
| (key,ws) <- myExtraWorkspaces
] ++ [ -- also for extra workspaces
((myModMask .|. shiftMask, key), (windows $ W.shift ws))
| (key,ws) <- myExtraWorkspaces
] ++ [ -- to swap workspaces
((mod1Mask .|. shiftMask, k), windows $ swapWithCurrent i)
| (i, k) <- zip myWorkspaces [xK_1 ..]
] -- ++ [
-- ((m .|. myModMask, k), windows $ f i)
-- | (i, k) <- zip (myWorkspaces x) [xK_1 ..]
-- , (f, m) <- [(copy, shiftMask .|. controlMask)]
-- ]
-- layouts
myGap = spacingRaw False (Border sGap sGap sGap sGap) True (Border wGap wGap wGap wGap) True
myLayouts = avoidStruts (
renamed [R.Replace "BSP"] (maximize $ fullscreenFocus $ windowNavigation $ myGap $ emptyBSP)
||| renamed [R.Replace "ThreeCol Mid (1)"] (maximize $ fullscreenFocus $ windowNavigation $ myGap $ ThreeColMid 1 (3/100) (1/2))
||| renamed [R.Replace "ThreeCol Mid (2)"] (maximize $ fullscreenFocus $ windowNavigation $ myGap $ ThreeColMid 2 (3/100) (1/2))
||| renamed [R.Replace "Grid"] (maximize $ fullscreenFocus $ windowNavigation $ myGap $ Grid)
||| renamed [R.Replace "TwoPane"] (maximize $ fullscreenFocus $ windowNavigation $ myGap $ TwoPane (3/100) (1/2))
||| renamed [R.Replace "ThreeCol (1)"] (maximize $ fullscreenFocus $ windowNavigation $ myGap $ ThreeCol 1 (3/100) (1/2))
||| renamed [R.Replace "ThreeCol (2)"] (maximize $ fullscreenFocus $ windowNavigation $ myGap $ ThreeCol 2 (3/100) (1/2))
)
myLayoutHook = myLayouts
myLemonbarPP = def {ppCurrent = wrap "%{B#d33682}" "%{B-}"
, ppWsSep = ""
, ppHidden = wrap "%{B#268bd2}" "%{B-}"
, ppHiddenNoWindows = wrap "%{F#02fc45}" "%{F-}"
, ppTitle = wrap " %{B#6c71c4}%{F#f0f0f0} " " %{B-}" . shorten 60
, ppUrgent = wrap "%{B#9cfc02} " " %{B-}%{F-}"
, ppLayout = wrap "%{r}%{B#99B1D5}%{F#232627} " " %{B-} "
, ppSep = " "
, ppExtras = [windowCount]
, ppOrder = \(ws:l:t:ex) -> [ws]++[t]++[l]++["%{B#50FA7B}%{F#232627} WIN:"]++ex++["%{B-}%{F-} "]
}
main = do
notXMobar <- spawnPipe "lemonbar -b -g 800x21+0+0 -B '#171520' -F '#ffffff' -f 'Source Han Sans JP:size=10' -o -3 -f 'RobotoMono Nerd Font:style=Regular:size=15' -f -n 'notXMobar' -o 0"
xmonad $ docks def
{
terminal = myTerminal,
focusFollowsMouse = True,
borderWidth = myBorderWidth,
modMask = myModMask,
workspaces = myWorkspaces,
normalBorderColor = nBorder,
focusedBorderColor = fBorder,
-- mouseBindings = myMouseBindings,
layoutHook = myLayoutHook,
manageHook = namedScratchpadManageHook myScratchpads <+> fullscreenManageHook,
handleEventHook = fullscreenEventHook,
logHook = dynamicLogWithPP myLemonbarPP { ppOutput = \x -> hPutStrLn notXMobar x},
startupHook = myStartupHook
} `additionalKeys` myKeys
|