]> Git — Sourcephile - julm/julm-nix.git/blob - home-manager/profiles/xmonad/xmonad.hs
+use/op(xmonad): add scratchpads
[julm/julm-nix.git] / home-manager / profiles / xmonad / xmonad.hs
1 {-# LANGUAGE GHC2024 #-}
2 {-# OPTIONS_GHC -Wall #-}
3 {-# OPTIONS_GHC -fno-warn-missing-signatures #-}
4 import Data.Default
5 import qualified Data.Char as Char
6 import Data.List as List
7 import Data.Ratio
8 import System.Exit
9 import qualified Data.Map as Map
10 import Control.Arrow (first)
11
12 -- import XMonad.Actions.DwmPromote
13 -- import XMonad.Actions.Warp
14 -- import XMonad.Layout.Maximize
15 -- import XMonad.Layout.Monitor
16 -- import XMonad.Layout.ResizableTile
17 -- import XMonad.Layout.TabBarDecoration
18 -- import XMonad.Util.EZConfig
19 -- import XMonad.Util.EZConfig(additionalKeys)
20 -- import XMonad.Util.WorkspaceCompare
21 import XMonad hiding ((|||))
22 import XMonad.Actions.CopyWindow
23 import XMonad.Actions.CycleWS
24 import XMonad.Actions.SwapWorkspaces
25 import XMonad.Actions.UpdatePointer
26 import XMonad.Config.Azerty
27 import XMonad.Hooks.DynamicLog
28 import XMonad.Hooks.EwmhDesktops
29 import XMonad.Hooks.ManageDocks
30 import XMonad.Hooks.ManageHelpers
31 import XMonad.Hooks.RefocusLast
32 import XMonad.Hooks.Rescreen
33 import XMonad.Hooks.SetWMName
34 import XMonad.Hooks.StatusBar
35 import XMonad.Hooks.UrgencyHook
36 import XMonad.Layout.Columns
37 import XMonad.Layout.Fullscreen
38 import XMonad.Layout.Grid
39 import XMonad.Layout.LayoutCombinators
40 import XMonad.Layout.Magnifier
41 import XMonad.Layout.MultiToggle
42 import XMonad.Layout.MultiToggle.Instances
43 import XMonad.Layout.NoBorders
44 import XMonad.Layout.ResizableTile
45 import XMonad.Layout.Spiral
46 import XMonad.Layout.Tabbed
47 import XMonad.Layout.ThreeColumns
48 import XMonad.Layout.WindowNavigation
49 import XMonad.ManageHook
50 import XMonad.Operations (unGrab)
51 import XMonad.Prompt
52 import XMonad.Prompt.FuzzyMatch
53 import XMonad.Prompt.Pass
54 import XMonad.Prompt.Window
55 import XMonad.Util.NamedScratchpad
56 import XMonad.Util.SpawnOnce
57 import qualified XMonad.StackSet as W
58
59 main = xmonad $
60 withUrgencyHook NoUrgencyHook $
61 -- dzenUrgencyHook { args = ["-bg", "darkgreen", "-xs", "1"] } $
62 --addAfterRescreenHook myAfterRescreenHook $
63 addRandrChangeHook (spawnExec "autorandr --change") $
64 dynamicSBs barSpawner $
65 docks $
66 setEwmhActivateHook doAskUrgent $
67 ewmhFullscreen $
68 ewmh $
69 azertyConfig
70 { borderWidth = 1
71 , focusFollowsMouse = True
72 , focusedBorderColor = "#00b10b"
73 , handleEventHook = handleEventHook def
74 , keys = \conf@XConfig{XMonad.modMask} ->
75 Map.fromList $
76 let xK_XF86Backward = 0x1008ff26
77 xK_XF86Forward = 0x1008ff27 in
78 [
79 -- Start a terminal
80 ((modMask, xK_Return), spawnExec $ XMonad.terminal conf)
81 -- Launch a program
82 , ((modMask, xK_Menu), spawnCommand)
83 , ((modMask, xK_space), spawnCommand)
84 -- Browse the filesystem
85 , ((modMask, xK_BackSpace), spawnExec "systemd-run --user --unit=app-org.rofi.caja@$RANDOM -p CollectMode=inactive-or-failed caja")
86
87 -- Lock the screen
88 , ((0, xK_Pause), unGrab >> spawnExec "loginctl lock-session \"$XDG_SESSION_ID\"")
89 , ((modMask, xK_Delete), unGrab >> spawnExec "loginctl lock-session \"$XDG_SESSION_ID\"")
90
91 -- Take a full screenshot
92 , ((0, xK_Print), spawn "mkdir -p ~/Images/screenshots && scrot --quality 42 ~/Images/screenshots/'%Y-%m-%d_%H-%M-%S.png' && caja ~/Images/screenshots")
93 -- Take a selective screenshot
94 , ((modMask, xK_Print), spawn "select-screenshot")
95
96 -- Volume control
97 , ((0, 0x1008FF12), spawnExec "pactl -- set-sink-mute @DEFAULT_SINK@ toggle") -- XF88AudioMute
98 , ((0, 0x1008FF11), spawnExec "pactl -- set-sink-volume @DEFAULT_SINK@ -5%") -- XF86AudioLowerVolume
99 , ((0, 0x1008FF13), spawnExec "pactl -- set-sink-volume @DEFAULT_SINK@ +5%") -- XF86AudioRaiseVolume
100 -- Audio previous
101 -- , ((0, 0x1008FF16), spawnExec "")
102 -- Play/pause
103 -- , ((0, 0x1008FF14), spawnExec "")
104 -- Audio next
105 -- , ((0, 0x1008FF17), spawnExec "")
106 -- Eject CD tray
107 -- , ((0, 0x1008FF2C), spawnExec "eject -T")
108
109 -- Close focused window.
110 , ((modMask, xK_Escape), kill)
111
112 -- Clipboard
113 , ((modMask, xK_c), spawnExec "clipster --select --primary")
114
115 -- Temporarily maximize a window
116 , ((modMask, xK_f), sendMessage $ XMonad.Layout.MultiToggle.Toggle FULL)
117 -- , ((modMask, xK_f), withFocused (sendMessage . maximizeRestore))
118
119 -- Cycle through the available layout algorithms
120 , ((modMask, 0x13bd), sendMessage NextLayout) -- oe (²)
121 , ((modMask, xK_ampersand), sendMessage $ JumpToLayout "ResizableTall") -- & (1)
122 , ((modMask, xK_eacute), sendMessage $ JumpToLayout "Mirror ResizableTall") -- é (2)
123 , ((modMask, xK_quotedbl), sendMessage $ JumpToLayout "Tabbed Simplest") -- ' (3)
124 , ((modMask, xK_apostrophe), sendMessage $ JumpToLayout "Magnifier Grid") -- " (4)
125 , ((modMask, xK_parenleft), sendMessage $ JumpToLayout "Spiral") -- ( (5)
126 , ((modMask, xK_minus), sendMessage $ JumpToLayout "Full") -- - (6)
127 , ((modMask, xK_egrave), sendMessage $ JumpToLayout "ThreeCol") -- è (7)
128 , ((modMask, xK_underscore), sendMessage $ JumpToLayout "Columns") -- _ (8)
129
130 -- Reset the layouts on the current workspace to default
131 -- , ((modMask .|. shiftMask, xK_space), setLayout $ XMonad.layoutHook conf)
132
133 -- Resize viewed windows to the correct size.
134 , ((modMask, xK_n), refresh)
135
136 -- Move focus to the master window
137 , ((modMask .|. shiftMask, xK_exclam), windows W.focusMaster)
138 -- Swap the focused window and the master window
139 , ((modMask, xK_exclam), windows W.swapMaster)
140
141 -- Swap the focused window with the next window.
142 --, ((modMask, xK_o), windows W.swapDown >> windows W.focusMaster)
143 -- Swap the focused window with the previous window.
144 , ((modMask, xK_m), windows W.swapUp >> windows W.focusMaster)
145
146 -- Move focus
147 , ((modMask, xK_h), sendMessage $ Go L)
148 , ((modMask, xK_m), sendMessage $ Go R)
149 --, ((modMask, xK_i), sendMessage $ Go U)
150 --, ((modMask, xK_k), sendMessage $ Go D)
151 , ((modMask, xK_i), windows W.focusUp)
152 , ((modMask, xK_k), windows W.focusDown)
153 , ((modMask, xK_j), prevWS)
154 , ((modMask, xK_l), nextWS)
155 , ((modMask, xK_Left), windows W.focusUp)
156 , ((modMask, xK_Right), windows W.focusDown)
157 --, ((modMask, xK_Left), onGroup W.focusUp')
158 --, ((modMask, xK_Right), onGroup W.focusDown')
159 , ((modMask, xK_Up), sendMessage $ Go U)
160 , ((modMask, xK_Down), sendMessage $ Go D)
161
162 -- Move windows
163 , ((modMask .|. shiftMask, xK_h), sendMessage MoveLeft)
164 , ((modMask .|. shiftMask, xK_m), sendMessage MoveRight)
165 , ((modMask .|. controlMask, xK_h), sendMessage MoveLeft)
166 , ((modMask .|. controlMask, xK_m), sendMessage MoveRight)
167 , ((modMask .|. controlMask, xK_i), sendMessage MoveUp)
168 , ((modMask .|. controlMask, xK_k), sendMessage MoveDown)
169 , ((modMask .|. controlMask, xK_j), shiftToPrev >> prevWS)
170 , ((modMask .|. controlMask, xK_l), shiftToNext >> nextWS)
171
172 -- Resize windows
173 , ((modMask .|. shiftMask, xK_l), sendMessage HorizontalExpand)
174 , ((modMask .|. shiftMask, xK_j), sendMessage HorizontalShrink)
175 , ((modMask .|. shiftMask, xK_i), sendMessage VerticalExpand)
176 , ((modMask .|. shiftMask, xK_k), sendMessage VerticalShrink)
177
178 -- Push window back into tiling.
179 , ((modMask, xK_t), withFocused $ windows . W.sink)
180
181 -- Change the number of windows in the master area
182 , ((modMask, xK_Up), sendMessage $ IncMasterN 1)
183 , ((modMask, xK_Down), sendMessage $ IncMasterN (-1))
184
185 -- Toggle the status bar gap.
186 , ((modMask, xK_b), sendMessage ToggleStruts)
187
188 -- Quit xmonad
189 , ((modMask .|. shiftMask, xK_End), io exitSuccess)
190 -- Restart xmonad
191 , ((modMask, xK_End), restart "xmonad" True)
192
193 , ((modMask, xK_p), passPrompt promptConfig)
194 , ((modMask .|. controlMask, xK_p), passGeneratePrompt promptConfig)
195 , ((modMask .|. controlMask .|. shiftMask, xK_p), passRemovePrompt promptConfig)
196 , ((modMask, xK_Tab), windowMultiPrompt promptConfig [(Goto, allWindows), (Goto, wsWindows)])
197
198 -- Workspace management
199 -- XF86Back: Switch to previous workspace
200 , ((0, xK_XF86Backward), prevWS)
201 , ((modMask, xK_Page_Up), prevWS)
202 -- Switch to next workspace
203 , ((0, xK_XF86Forward), nextWS)
204 , ((modMask, xK_Page_Down), nextWS)
205 -- XF86Back: Move the current client to the previous workspace and go there
206 , ((modMask, xK_XF86Backward), shiftToPrev >> prevWS)
207 -- Move the current client to the next workspace and go there
208 , ((modMask, xK_XF86Forward), shiftToNext >> nextWS)
209 -- Switch to previous workspace
210 -- Switch to next workspace
211 {-
212 -- Move the current client to the previous workspace
213 , ((0 .|. shiftMask , xK_XF86Backward), shiftToPrev )
214 -- Move the current client to the next workspace
215 , ((0 .|. shiftMask , xK_XF86Forward), shiftToNext )
216 -}
217
218 -- Toggle copying window on all workspaces (sticky window)
219 , ((modMask, xK_s), do
220 copies <- wsContainingCopies -- NOTE: consider only hidden workspaces
221 case copies of
222 [] -> windows copyToAll
223 _ -> killAllOtherCopies
224 )
225
226 -- Resize the master area
227 --, ((modMask, xK_Left), sendMessage Shrink)
228 --, ((modMask, xK_Right), sendMessage Expand)
229 -- Resize windows in ResizableTall mode
230 --, ((modMask .|. shiftMask, xK_Left), sendMessage MirrorShrink)
231 --, ((modMask .|. shiftMask, xK_Right), sendMessage MirrorExpand)
232 ] ++
233
234 -- Dynamic scratchpads
235 (mconcat
236 [ [ ((modMask .|. altMask .|. controlMask, key), withFocused $ toggleDynamicNSP name)
237 , ((modMask .|. altMask, key), dynamicNSPAction name)
238 ]
239 | (key, chr) <- zip [xK_a..] ['a'..'z']
240 , let name = [chr]
241 ]
242 ) ++
243
244 -- Named scratchpads
245 -- Note: those keybindings override dynamic scratchpads above
246 [ ((modMask .|. altMask, xK_b), namedScratchpadAction scratchpads "btop")
247 , ((modMask .|. altMask, xK_c), namedScratchpadAction scratchpads "中文")
248 , ((modMask .|. altMask, xK_e), namedScratchpadAction scratchpads "english")
249 , ((modMask .|. altMask, xK_h), namedScratchpadAction scratchpads "htop")
250 , ((modMask .|. altMask, xK_m), namedScratchpadAction scratchpads "matrix")
251 , ((modMask .|. altMask, xK_n), namedScratchpadAction scratchpads "notes")
252 , ((modMask .|. altMask, xK_o), namedScratchpadAction scratchpads "concerns")
253 , ((modMask .|. altMask, xK_s), namedScratchpadAction scratchpads "signal")
254 , ((modMask .|. altMask, xK_space), namedScratchpadAction scratchpads "terminal")
255 , ((modMask .|. altMask, xK_Return), namedScratchpadAction scratchpads "terminal")
256 , ((modMask .|. altMask, xK_BackSpace), resetFocusedNSP)
257 ] ++
258
259 -- mod-[F1..F9], Switch to workspace N
260 -- mod-shift-[F1..F9], Move client to workspace N
261 [ ((m .|. modMask, k), windows $ f i)
262 | (i, k) <- zip (workspaces conf) [xK_F1 ..] ++
263 zip (workspaces conf) [xK_1 ..]
264 , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]
265 ] ++
266 {- NOTE: with Xinerama
267 [((m .|. modMask, k), windows $ onCurrentScreen f i)
268 | (i, k) <- zip (workspaces' conf) [xK_F1 ..]
269 , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)] ]
270 -}
271
272 -- mod-{w,e,r}, Switch to physical/Xinerama screens 1, 2, or 3
273 -- mod-shift-{w,e,r}, Move client to screen 1, 2, or 3
274 [ ((m .|. modMask, key), screenWorkspace sc >>= flip whenJust (windows . f))
275 | (key, sc) <- zip [xK_w, xK_e, xK_r] [0 ..]
276 , (f, m) <- [(W.view, 0), (W.shift, shiftMask)]
277 ] ++
278
279 -- mod-shift-[F1..F9], Swap workspace with workspace N
280 -- mod-shift-[1..9], Swap workspace with workspace N
281 [ ((modMask .|. controlMask, k), windows $ swapWithCurrent i)
282 | (i, k) <- zip (workspaces conf) [xK_F1 ..] ++
283 zip (workspaces conf) [xK_1 ..]
284 ]
285 {- NOTE: with Xinerama
286 [((modMask .|. controlMask, k), windows $ onCurrentScreen swapWithCurrent i)
287 | (i, k) <- zip (workspaces' conf) [xK_F1 ..] ]
288 -}
289 , layoutHook = smartBorders $
290 mkToggle (NOBORDERS ?? FULL ?? EOT) $ -- enable temporarily maximizing a window
291 avoidStruts $ -- prevents windows from overlapping dock windows
292 let tall = ResizableTall 1 (1%200) (8%13) [] in
293 windowNavigation $
294 -- addTabs shrinkText tabBar (subLayout [] Simplest (Columns 1 []))
295 Columns 1 []
296 ||| tabbed shrinkText tabConfig
297 ||| tall
298 ||| Mirror tall
299 ||| magnifiercz (13%10) Grid
300 ||| spiral (6%7)
301 ||| noBorders (fullscreenFull Full)
302 ||| ThreeColMid 1 (1%200) (1%2)
303 -- ||| Tall 1 (3/100) (1/2)
304 , manageHook = composeAll
305 -- [ , isFullscreen --> (doF W.focusDown <+> doFullFloat)
306 [ isFullscreen --> doFullFloat
307 , manageHook def
308 , manageDocks -- NOTE: do not tile dock windows
309 , namedScratchpadManageHook scratchpads
310 , resource =? "desktop_window" --> doIgnore
311 , className =? "Gimp" --> doFloat
312 , resource =? "gpicview" --> doSink
313 , className =? "mpv" --> doFloat
314 , className =? "ultrastardx" --> doSink
315 --, className =? "MPlayer" --> doShift "3:media" -- <+> doFloat
316 --, className =? "vlc" --> doShift "3:media"
317 , className =? "trayer" --> doIgnore
318 ]
319 , modMask = mod4Mask
320 , mouseBindings = \XConfig{XMonad.modMask} ->
321 Map.fromList
322 [
323 -- mod-button1, Set the window to floating mode and move by dragging
324 ((modMask, button1), floatMoveNoexclusive)
325
326 -- mod-button2, Raise the window to the top of the stack
327 , ((modMask, button2), \w -> focus w >> windows W.swapMaster)
328
329 -- mod-button3, Set the window to floating mode and resize by dragging
330 , ((modMask, button3), resizeNoexclusive)
331
332 , ((modMask, button4), \_ -> windows W.focusUp)
333 , ((modMask, button5), \_ -> windows W.focusDown)
334
335 -- Cycle through workspaces
336 , ((controlMask .|. modMask, button5), nextNonEmptyWS)
337 , ((controlMask .|. modMask, button4), prevNonEmptyWS)
338 ]
339 , normalBorderColor = "#7C7C7C"
340 , startupHook =
341 setWMName "XMonad"
342 <+> addExclusives exclusiveScratchpads
343 <+> spawnExec "wmname XMonad"
344 <+> spawnExec "xrdb -all .Xresources"
345 <+> spawn "sleep 1 && xmodmap .Xmodmap"
346 <+> spawnExec "xset r rate 250 25"
347 <+> spawnExec "xinput --set-button-map 'Logitech USB Receiver Mouse' 1 2 3 4 5 6 7 2"
348 <+> spawnExec "xset b off"
349 <+> spawnExec "xhost local:root"
350 <+> spawnExec "setxkbmap -option keypad:pointerkeys"
351 -- Useful for programs launched by rofi
352 <+> spawnExec (unwords [ "systemctl --user import-environment"
353 , "DBUS_SESSION_BUS_ADDRESS"
354 , "GDK_PIXBUF_MODULE_FILE"
355 , "GIO_EXTRA_MODULES"
356 , "GLFW_IM_MODULE"
357 , "GNUPGHOME"
358 , "GTK2_RC_FILES"
359 , "GTK_A11Y"
360 , "GTK_IM_MODULE"
361 , "GTK_PATH"
362 , "LANG"
363 , "LD_LIBRARY_PATH" -- For sane and pipewire
364 , "LIBEXEC_PATH"
365 , "NIX_PROFILES" -- fcitx5 does not work without it…
366 , "PASSWORD_STORE_DIR"
367 , "PATH"
368 , "QTWEBKIT_PLUGIN_PATH"
369 , "QT_IM_MODULE"
370 , "QT_PLUGIN_PATH"
371 , "SPEECHD_CMD"
372 , "SSH_ASKPASS"
373 , "XCURSOR_PATH"
374 , "XMODIFIERS"
375 ])
376 -- <+> spawnOnce "exec arbtt-capture -r 60"
377 -- <+> spawnOnce "exec parcellite"
378 -- <+> spawnOnce "exec xautolock"
379 -- <+> spawnOnce "exec redshift-gtk -l -45.7800:1.9700 -t 6500:3700"
380 <+> spawnOnce "exec nm-applet"
381 , terminal = "$TERMINAL"
382 , workspaces = {- withScreens nScreens $ -}
383 {-["1:work","2:web","3:media"] ++-}
384 map show [1::Int .. 9]
385 , logHook = do
386 -- updatePointer (Relative 0.5 0.5)
387 refocusLastLogHook
388 nsHideOnFocusLoss scratchpads
389 updatePointer (0.5, 0.5) (0, 0)
390 }
391 where
392 tabConfig = def
393 { activeBorderColor = "#7C7C7C"
394 , activeColor = "#000000"
395 , activeTextColor = "#00FF00"
396 , inactiveBorderColor = "#7C7C7C"
397 , inactiveColor = "#000000"
398 , inactiveTextColor = "#EEEEEE"
399 , fontName = "Hack 7"
400 }
401
402 spawnCommand = spawnExec "rofi -show run -no-disable-history -run-command \"bash -c 'systemd-run --user --unit=app-org.rofi.\\$(systemd-escape \\\"{cmd}\\\")@\\$RANDOM -p CollectMode=inactive-or-failed {cmd}'\""
403
404 barSpawner :: ScreenId -> X StatusBarConfig
405 barSpawner 0 = pure $ topXmobar <> traySB
406 --barSpawner 1 = pure $ xmobar1
407 barSpawner _ = pure $ topXmobar -- nothing on the rest of the screens
408
409 -- Display properties of the root window:
410 -- xprop -display $DISPLAY -root
411 topXmobar = statusBarPropTo "_XMONAD_XMOBAR0" "xmobar -x 0 ~/.config/xmonad/xmobar0.hs" (pure topPP)
412 where
413 topPP =
414 xmobarPP
415 { ppCurrent = xmobarColor "black" "#CCCCCC"
416 , ppHidden = xmobarColor "#CCCCCC" "black"
417 , ppHiddenNoWindows = xmobarColor "#606060" "black"
418 , ppLayout = \s -> xmobarColor "black" "#606060" $
419 case s of
420 "Columns" -> " \" "
421 "ResizableTall" -> " | "
422 "Mirror ResizableTall" -> " - "
423 "Tabbed Simplest" -> " + "
424 "Magnifier Grid" -> " ~ "
425 "Spiral" -> " @ "
426 "Full" -> " O "
427 "ThreeCol" -> " # "
428 _ -> s
429 , ppSep = " "
430 , ppTitle = xmobarColor "white" "black" . shorten 50
431 , ppUrgent = xmobarColor "yellow" "black"
432 , ppWsSep = " "
433 }
434
435 traySB :: StatusBarConfig
436 traySB =
437 statusBarGeneric
438 ( List.unwords
439 [ "trayer"
440 , "--align right"
441 , "--distance 0,0"
442 , "--distancefrom top,right"
443 , "--edge top"
444 , "--expand true"
445 , "--height 16"
446 , "--monitor primary"
447 , "--tint 0x000000"
448 , "--iconspacing 0"
449 , "--transparent true"
450 , "--widthtype request"
451 , "-l"
452 ]
453 )
454 mempty
455
456 nextNonEmptyWS _ = moveTo Next (WSIs ((not .) <$> isWindowSpaceVisible))
457 prevNonEmptyWS _ = moveTo Prev (WSIs ((not .) <$> isWindowSpaceVisible))
458
459 isWindowSpaceVisible :: X (WindowSpace -> Bool)
460 isWindowSpaceVisible = do
461 vs <- gets (map (W.tag . W.workspace) . W.visible . windowset)
462 return (\w -> W.tag w `elem` vs)
463
464 spawnExec s = spawn $ List.unwords $ [ "exec" ] <> systemdCat <> [ s ]
465 systemdCat = [ "systemd-cat" , "--priority=info", "--stderr-priority=warning", "--level-prefix=false" , "--" ]
466
467 promptConfig :: XPConfig
468 promptConfig = def
469 { font = "xft:monospace-"<>show fontSize
470 , bgColor = "black"
471 , fgColor = "grey"
472 , bgHLight = "green"
473 , fgHLight = "#000000"
474 , borderColor = "darkgreen"
475 , promptBorderWidth = 1
476 , promptKeymap = promptKeyMap
477 , position = CenteredAt { xpCenterY = 0.3, xpWidth = 0.5 }
478 , height = fontSize + 11
479 , historySize = 16
480 , historyFilter = id
481 , defaultText = ""
482 , autoComplete = Nothing -- Just 500000 -- nanoseconds
483 , showCompletionOnTab = False
484 , completionKey = (0, xK_Down)
485 , prevCompletionKey = (0, xK_Up)
486 , searchPredicate = fuzzyMatch -- isPrefixOf
487 , sorter = fuzzySort
488 , defaultPrompter = const ""
489 , alwaysHighlight = True
490 , maxComplRows = Just 10
491 , maxComplColumns = Just 1
492 , changeModeKey = xK_twosuperior
493 }
494 where
495 fontSize = 11
496
497 promptKeyMap :: Map.Map (KeyMask,KeySym) (XP ())
498 promptKeyMap = Map.fromList $
499 List.map (first $ (,) controlMask) -- control + <key>
500 [ (xK_z, killBefore) -- kill line backwards
501 , (xK_k, killAfter) -- kill line forwards
502 , (xK_u, killBefore) -- kill line backwards
503 , (xK_a, startOfLine) -- move to the beginning of the line
504 , (xK_e, endOfLine) -- move to the end of the line
505 , (xK_m, deleteString Next) -- delete a character foward
506 , (xK_b, moveCursor Prev) -- move cursor forward
507 , (xK_f, moveCursor Next) -- move cursor backward
508 , (xK_BackSpace, killWord Prev) -- kill the previous word
509 , (xK_y, pasteString) -- paste a string
510 , (xK_g, quit) -- quit out of prompt
511 , (xK_bracketleft, quit)
512 ]
513 ++
514 List.map (first $ (,) altMask) -- meta key + <key>
515 [ (xK_BackSpace, killWord Prev) -- kill the prev word
516 , (xK_f, moveWord Next) -- move a word forward
517 , (xK_b, moveWord Prev) -- move a word backward
518 , (xK_d, killWord Next) -- kill the next word
519 , (xK_n, moveHistory W.focusUp') -- move up through history
520 , (xK_p, moveHistory W.focusDown') -- move down through history
521 ]
522 ++
523 List.map (first $ (,) 0) -- <key>
524 [ (xK_Return, setSuccess True >> setDone True)
525 , (xK_KP_Enter, setSuccess True >> setDone True)
526 , (xK_BackSpace, deleteString Prev)
527 , (xK_Delete, deleteString Next)
528 , (xK_Left, moveCursor Prev)
529 , (xK_Right, moveCursor Next)
530 , (xK_Home, startOfLine)
531 , (xK_End, endOfLine)
532 , (xK_Down, moveHistory W.focusUp')
533 , (xK_Up, moveHistory W.focusDown')
534 , (xK_Escape, quit)
535 ]
536
537 altMask :: KeyMask
538 altMask = mod1Mask
539
540 -- HowTo(develop): use xprop to see window properties to query them
541 scratchpads =
542 [ NS { name = "btop", cmd = "$TERMINAL --title=btop -e btop", query = title =? "btop", hook }
543 , NS { name = "concerns", cmd = "$TERMINAL --title=concerns -e sh -c 'cd $HOME/work/sourcephile && vi Concerns.md'", query = title =? "concerns", hook }
544 , NS { name = "english", cmd = "$TERMINAL --title=english -e sh -c 'cd $HOME/files/notes/english && vi vocabulary.org'", query = title =? "english", hook }
545 , NS { name = "htop", cmd = "$TERMINAL --title=htop -e htop", query = title =? "htop", hook }
546 , NS { name = "matrix", cmd = "element-desktop", query = className =? "Element", hook }
547 , NS { name = "signal", cmd = "signal-desktop", query = className =? "Signal", hook }
548 , NS { name = "notes", cmd = "$TERMINAL --title=notes -e sh -c 'cd $HOME/files/notes && vi notes.md'", query = title =? "notes", hook }
549 , NS { name = "terminal", cmd = "$TERMINAL --title=scratch-term", query = title =? "scratch-term", hook }
550 , NS { name = "中文", cmd = "$TERMINAL --title=中文 -e sh -c 'cd $HOME/files/notes/中文 && vi Vocabulary.hs'", query = title =? "中文", hook }
551 ]
552 where hook = customFloating (W.RationalRect (1/2) (0) (1/2) (1))
553
554 exclusiveScratchpads = [ [ name | NS{name} <- scratchpads ] ]