Advertisement
Guest User

Untitled

a guest
Dec 31st, 2024
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 27.11 KB | None | 0 0
  1. -- Base
  2. import XMonad
  3. import System.Directory
  4. import System.IO (hPutStrLn)
  5. import System.Exit (exitSuccess)
  6. import qualified XMonad.StackSet as W
  7.  
  8. -- Actions
  9. import XMonad.Actions.CopyWindow (kill1)
  10. import XMonad.Actions.CycleWS (Direction1D(..), moveTo, shiftTo, WSType(..), nextScreen, prevScreen, shiftNextScreen, shiftPrevScreen)
  11. import XMonad.Actions.GridSelect
  12. import XMonad.Actions.MouseResize
  13. import XMonad.Actions.Promote
  14. import XMonad.Actions.RotSlaves (rotSlavesDown, rotAllDown)
  15. import XMonad.Actions.WindowGo (runOrRaise)
  16. import XMonad.Actions.WithAll (sinkAll, killAll)
  17. import qualified XMonad.Actions.Search as S
  18. import XMonad.Actions.SpawnOn
  19.  
  20. -- Data
  21. import Data.Char (isSpace, toUpper)
  22. import Data.Maybe (fromJust)
  23. import Data.Monoid
  24. import Data.Maybe (isJust)
  25. import Data.Tree
  26. import qualified Data.Map as M
  27.  
  28. -- Hooks
  29. import XMonad.Hooks.DynamicLog (dynamicLogWithPP, wrap, xmobarPP, xmobarColor, shorten, PP(..))
  30. import XMonad.Hooks.EwmhDesktops
  31. import XMonad.Hooks.ManageDocks (avoidStruts, docksEventHook, manageDocks, ToggleStruts(..))
  32. import XMonad.Hooks.ManageHelpers (isFullscreen, doFullFloat, doCenterFloat)
  33. import XMonad.Hooks.ServerMode
  34. import XMonad.Hooks.SetWMName
  35. import XMonad.Hooks.WorkspaceHistory
  36.  
  37. -- Layouts
  38. import XMonad.Layout.Accordion
  39. import XMonad.Layout.GridVariants (Grid(Grid))
  40. import XMonad.Layout.SimplestFloat
  41. import XMonad.Layout.Spiral
  42. import XMonad.Layout.ResizableTile
  43. import XMonad.Layout.Tabbed
  44. import XMonad.Layout.ThreeColumns
  45.  
  46. -- Layouts modifiers
  47. import XMonad.Layout.LayoutModifier
  48. import XMonad.Layout.LimitWindows (limitWindows, increaseLimit, decreaseLimit)
  49. import XMonad.Layout.Magnifier
  50. import XMonad.Layout.MultiToggle (mkToggle, single, EOT(EOT), (??))
  51. import XMonad.Layout.MultiToggle.Instances (StdTransformers(NBFULL, MIRROR, NOBORDERS))
  52. import XMonad.Layout.NoBorders
  53. import XMonad.Layout.Renamed
  54. import XMonad.Layout.ShowWName
  55. import XMonad.Layout.Simplest
  56. import XMonad.Layout.Spacing
  57. import XMonad.Layout.SubLayouts
  58. import XMonad.Layout.WindowArranger (windowArrange, WindowArrangerMsg(..))
  59. import XMonad.Layout.WindowNavigation
  60. import qualified XMonad.Layout.ToggleLayouts as T (toggleLayouts, ToggleLayout(Toggle))
  61. import qualified XMonad.Layout.MultiToggle as MT (Toggle(..))
  62.  
  63. -- Utilities
  64. import XMonad.Util.Dmenu
  65. import XMonad.Util.EZConfig (additionalKeysP)
  66. import XMonad.Util.NamedScratchpad
  67. import XMonad.Util.Run (runProcessWithInput, safeSpawn, spawnPipe)
  68. import XMonad.Util.SpawnOnce
  69. import XMonad.Util.Cursor
  70. import XMonad.Actions.OnScreen
  71. import XMonad.Hooks.DynamicIcons (IconConfig (..), appIcon,
  72. dynamicLogIconsWithPP,
  73. dynamicIconsPP,
  74. iconsPP,
  75. iconsFmtReplace,
  76. iconsGetFocus,
  77. wrapUnwords)
  78. import XMonad.Hooks.StatusBar (StatusBarConfig,
  79. statusBarProp,
  80. statusBarPropTo, withSB)
  81. import XMonad.Hooks.StatusBar.PP (PP (..), filterOutWsPP,
  82. shorten', wrap,
  83. xmobarAction,
  84. xmobarBorder, xmobarColor,
  85. xmobarFont, xmobarStrip)
  86. import XMonad.Util.ClickableWorkspaces (clickablePP)
  87.  
  88. myFont :: String
  89. myFont = "xft:SauceCodePro Nerd Font Mono:regular:size=9:antialias=true:hinting=true"
  90. -- myFont = "xft:JetBrainsMono Nerd Font:size=14"
  91. myModMask :: KeyMask
  92. myModMask = mod1Mask -- Sets modkey to alt key
  93. -- myModMask = mod4Mask -- Sets modkey to super/windows key
  94.  
  95. myTerminal :: String
  96. myTerminal = "alacritty" -- Sets default terminal
  97.  
  98. myBrowser :: String
  99. myBrowser = "firefox-bin" -- Sets firefox as Browser
  100.  
  101. myMail :: String
  102. myMail = "thunderbird-bin" -- Sets evolution as mail client
  103.  
  104. myFiles :: String
  105. myFiles = "pcmanfm" -- Sets nautilus as file browser
  106.  
  107. myEmacs :: String
  108. myEmacs = "emacsclient -c -a 'emacs' " -- Makes emacs keybindings easier to type
  109.  
  110. myEditor :: String
  111. myEditor = "emacsclient -c -a 'emacs' " -- Sets emacs as editor
  112.  
  113. myBorderWidth :: Dimension
  114. myBorderWidth = 2 -- Sets border width for windows
  115.  
  116. myNormColor :: String
  117. myNormColor = "#282c34" -- Border color of normal windows
  118.  
  119. myFocusColor :: String
  120. myFocusColor = "#46d9ff" -- Border color of focused windows
  121.  
  122. windowCount :: X (Maybe String)
  123. windowCount = gets $ Just . show . length . W.integrate' . W.stack . W.workspace . W.current . windowset
  124.  
  125. myStartupHook :: X ()
  126. myStartupHook = do
  127. -- spawnOnce "~/.screenlayout/mylayout.sh"
  128. spawnOnce "/usr/libexec/polkit-gnome-authentication-agent-1 &"
  129. spawnOnce "picom --config $HOME/.config/picom.conf --experimental-backends &"
  130. spawnOnce "nm-applet &"
  131. spawnOnce "volumeicon &"
  132. spawnOnce "xscreensaver --no-splash &"
  133. spawnOnce "trayer-srg --edge top --align right --widthtype request --padding 6 --SetDockType true --SetPartialStrut true --expand true --transparent true --alpha 0 --tint 0x282c34 --height 24 --monitor 1 &"
  134. spawnOnce "/usr/bin/emacs --daemon &" -- emacs daemon for the emacsclient
  135. spawnOnce "find /home/pascal/Pictures/wallpapers -type f | shuf -n 1 | xargs xwallpaper --output HDMI-A-0 --stretch"
  136. spawnOnce "find /home/pascal/Pictures/wallpapers -type f | shuf -n 1 | xargs xwallpaper --output DVI-D-1 --stretch"
  137. spawnOnce "find /home/pascal/Pictures/wallpapers -type f | shuf -n 1 | xargs xwallpaper --output DVI-D-0 --stretch"
  138. spawnOnOnce " <fn=5>\xf745</fn> " "firefox-bin"
  139. spawnOnOnce " <fn=5>\xe795</fn> " "alacritty"
  140. spawnOnOnce " <fn=5>\xe7cf</fn> " "emacsclient -c -a 'emacs'"
  141. spawnOnOnce " <fn=5>\xe5fe</fn> " "pcmanfm"
  142. spawnOnOnce " <fn=5>\xf0e0</fn> " "thunderbird-bin"
  143. spawnOnce "nextcloud --background"
  144. spawnOnce "gnome-encfs-manager"
  145. setWMName "LG3D"
  146. setDefaultCursor xC_left_ptr
  147. windows (greedyViewOnScreen 0 " <fn=5>\xf745</fn> ")
  148. windows (greedyViewOnScreen 1 " <fn=5>\xe7cf</fn> ")
  149. windows (greedyViewOnScreen 2 " <fn=5>\xe795</fn> ")
  150.  
  151. myColorizer :: Window -> Bool -> X (String, String)
  152. myColorizer = colorRangeFromClassName
  153. (0x28,0x2c,0x34) -- lowest inactive bg
  154. (0x28,0x2c,0x34) -- highest inactive bg
  155. (0xc7,0x92,0xea) -- active bg
  156. (0xc0,0xa7,0x9a) -- inactive fg
  157. (0x28,0x2c,0x34) -- active fg
  158.  
  159. -- gridSelect menu layout
  160. mygridConfig :: p -> GSConfig Window
  161. mygridConfig colorizer = (buildDefaultGSConfig myColorizer)
  162. { gs_cellheight = 40
  163. , gs_cellwidth = 200
  164. , gs_cellpadding = 6
  165. , gs_originFractX = 0.5
  166. , gs_originFractY = 0.5
  167. , gs_font = myFont
  168. }
  169.  
  170. spawnSelected' :: [(String, String)] -> X ()
  171. spawnSelected' lst = gridselect conf lst >>= flip whenJust spawn
  172. where conf = def
  173. { gs_cellheight = 40
  174. , gs_cellwidth = 200
  175. , gs_cellpadding = 6
  176. , gs_originFractX = 0.5
  177. , gs_originFractY = 0.5
  178. , gs_font = myFont
  179. }
  180.  
  181. myAppGrid = [ ("Audacity", "audacity")
  182. , ("Deadbeef", "deadbeef")
  183. , ("Emacs", "emacsclient -c -a emacs")
  184. , ("Firefox", "firefox")
  185. , ("Geany", "geany")
  186. , ("Geary", "geary")
  187. , ("Gimp", "gimp")
  188. , ("Kdenlive", "kdenlive")
  189. , ("LibreOffice Impress", "loimpress")
  190. , ("LibreOffice Writer", "lowriter")
  191. , ("OBS", "obs")
  192. , ("PCManFM", "pcmanfm")
  193. ]
  194.  
  195. myScratchPads :: [NamedScratchpad]
  196. myScratchPads = [ NS "terminal" spawnTerm findTerm manageTerm
  197. , NS "mocp" spawnMocp findMocp manageMocp
  198. , NS "calculator" spawnCalc findCalc manageCalc
  199. ]
  200. where
  201. spawnTerm = myTerminal ++ " -t scratchpad"
  202. findTerm = title =? "scratchpad"
  203. manageTerm = customFloating $ W.RationalRect l t w h
  204. where
  205. h = 0.9
  206. w = 0.9
  207. t = 0.95 -h
  208. l = 0.95 -w
  209. spawnMocp = myTerminal ++ " -t mocp -e mocp"
  210. findMocp = title =? "mocp"
  211. manageMocp = customFloating $ W.RationalRect l t w h
  212. where
  213. h = 0.9
  214. w = 0.9
  215. t = 0.95 -h
  216. l = 0.95 -w
  217. spawnCalc = "qalculate-gtk"
  218. findCalc = className =? "Qalculate-gtk"
  219. manageCalc = customFloating $ W.RationalRect l t w h
  220. where
  221. h = 0.5
  222. w = 0.4
  223. t = 0.75 -h
  224. l = 0.70 -w
  225.  
  226. --Makes setting the spacingRaw simpler to write. The spacingRaw module adds a configurable amount of space around windows.
  227. mySpacing :: Integer -> l a -> XMonad.Layout.LayoutModifier.ModifiedLayout Spacing l a
  228. mySpacing i = spacingRaw False (Border i i i i) True (Border i i i i) True
  229.  
  230. -- Below is a variation of the above except no borders are applied
  231. -- if fewer than two windows. So a single window has no gaps.
  232. mySpacing' :: Integer -> l a -> XMonad.Layout.LayoutModifier.ModifiedLayout Spacing l a
  233. mySpacing' i = spacingRaw True (Border i i i i) True (Border i i i i) True
  234.  
  235. -- Defining a bunch of layouts, many that I don't use.
  236. -- limitWindows n sets maximum number of windows displayed for layout.
  237. -- mySpacing n sets the gap size around the windows.
  238. tall = renamed [Replace "tall"]
  239. $ smartBorders
  240. $ windowNavigation
  241. $ addTabs shrinkText myTabTheme
  242. $ subLayout [] (smartBorders Simplest)
  243. $ limitWindows 12
  244. $ mySpacing 8
  245. $ ResizableTall 1 (3/100) (1/2) []
  246. -- magnify = renamed [Replace "magnify"]
  247. -- $ smartBorders
  248. -- $ windowNavigation
  249. -- $ addTabs shrinkText myTabTheme
  250. -- $ subLayout [] (smartBorders Simplest)
  251. -- $ magnifier
  252. -- $ limitWindows 12
  253. -- $ mySpacing 8
  254. -- $ ResizableTall 1 (3/100) (1/2) []
  255. monocle = renamed [Replace "monocle"]
  256. $ smartBorders
  257. $ windowNavigation
  258. $ addTabs shrinkText myTabTheme
  259. $ subLayout [] (smartBorders Simplest)
  260. $ limitWindows 20 Full
  261. floats = renamed [Replace "floats"]
  262. $ smartBorders
  263. $ limitWindows 20 simplestFloat
  264. grid = renamed [Replace "grid"]
  265. $ smartBorders
  266. $ windowNavigation
  267. $ addTabs shrinkText myTabTheme
  268. $ subLayout [] (smartBorders Simplest)
  269. $ limitWindows 12
  270. $ mySpacing 8
  271. $ mkToggle (single MIRROR)
  272. $ Grid (16/10)
  273. spirals = renamed [Replace "spirals"]
  274. $ smartBorders
  275. $ windowNavigation
  276. $ addTabs shrinkText myTabTheme
  277. $ subLayout [] (smartBorders Simplest)
  278. $ mySpacing' 8
  279. $ spiral (6/7)
  280. threeCol = renamed [Replace "threeCol"]
  281. $ smartBorders
  282. $ windowNavigation
  283. $ addTabs shrinkText myTabTheme
  284. $ subLayout [] (smartBorders Simplest)
  285. $ limitWindows 7
  286. $ ThreeCol 1 (3/100) (1/2)
  287. threeRow = renamed [Replace "threeRow"]
  288. $ smartBorders
  289. $ windowNavigation
  290. $ addTabs shrinkText myTabTheme
  291. $ subLayout [] (smartBorders Simplest)
  292. $ limitWindows 7
  293. -- Mirror takes a layout and rotates it by 90 degrees.
  294. -- So we are applying Mirror to the ThreeCol layout.
  295. $ Mirror
  296. $ ThreeCol 1 (3/100) (1/2)
  297. tabs = renamed [Replace "tabs"]
  298. -- I cannot add spacing to this layout because it will
  299. -- add spacing between window and tabs which looks bad.
  300. $ tabbed shrinkText myTabTheme
  301. tallAccordion = renamed [Replace "tallAccordion"]
  302. $ Accordion
  303. wideAccordion = renamed [Replace "wideAccordion"]
  304. $ Mirror Accordion
  305.  
  306. -- setting colors for tabs layout and tabs sublayout.
  307. myTabTheme = def { fontName = myFont
  308. , activeColor = "#46d9ff"
  309. , inactiveColor = "#313846"
  310. , activeBorderColor = "#46d9ff"
  311. , inactiveBorderColor = "#282c34"
  312. , activeTextColor = "#282c34"
  313. , inactiveTextColor = "#d0d0d0"
  314. }
  315.  
  316. -- Theme for showWName which prints current workspace when you change workspaces.
  317. --myShowWNameTheme :: SWNConfig
  318. --myShowWNameTheme = def
  319. -- { swn_font = "xft:JetBrainsMono Nerd Font:size=60"
  320. -- , swn_fade = 1.0
  321. -- , swn_bgcolor = "#1c1f24"
  322. -- , swn_color = "#ffffff"
  323. -- }
  324.  
  325. -- The layout hook
  326. myLayoutHook = avoidStruts $ mouseResize $ windowArrange $ T.toggleLayouts floats
  327. $ mkToggle (NBFULL ?? NOBORDERS ?? EOT) myDefaultLayout
  328. where
  329. myDefaultLayout = withBorder myBorderWidth tall
  330. -- ||| magnify
  331. ||| noBorders monocle
  332. ||| floats
  333. ||| noBorders tabs
  334. ||| grid
  335. ||| spirals
  336. ||| threeCol
  337. ||| threeRow
  338. ||| tallAccordion
  339. ||| wideAccordion
  340.  
  341. -- myWorkspaces = [" 1 ", " 2 ", " 3 ", " 4 ", " 5 ", " 6 ", " 7 ", " 8 ", " 9 "]
  342. myWorkspaces = [" <fn=5>\xe745</fn> ", " <fn=5>\xe7cf</fn> ", " <fn=5>\xe795</fn> ", " <fn=5>\xe5fe</fn> ", " <fn=5>\xf0e0</fn> ", " <fn=5>\xf03b3</fn> ", " <fn=5>\xf03b6</fn> ", " <fn=5>\xf03b9</fn> ", " <fn=5>\xf03bc</fn> "]
  343. -- myWorkspaces = [" <fn=5>\xf269</fn> ", " <fn=5>\xe7cf</fn> ", " <fn=5>\xe795</fn> ", " <fn=5>\xf07c</fn> ", " <fn=5>\xf0e0</fn> ", " <fn=5>\xf8b2</fn> ", " <fn=5>\xf8b5</fn> ", " <fn=5>\xf8b8</fn> ", " <fn=5>\xf8bb</fn> "]
  344.  
  345. myWorkspaceIndices = M.fromList $ zipWith (,) myWorkspaces [1..] -- (,) == \x y -> (x,y)
  346.  
  347. clickable ws = "<action=xdotool key alt+"++show i++">"++ws++"</action>"
  348. where i = fromJust $ M.lookup ws myWorkspaceIndices
  349.  
  350. myManageHook :: XMonad.Query (Data.Monoid.Endo WindowSet)
  351. myManageHook = composeAll
  352. -- 'doFloat' forces a window to float. Useful for dialog boxes and such.
  353. -- using 'doShift ( myWorkspaces !! 7)' sends program to workspace 8!
  354. -- I'm doing it this way because otherwise I would have to write out the full
  355. -- name of my workspaces and the names would be very long if using clickable workspaces.
  356. [ className =? "confirm" --> doFloat
  357. , className =? "file_progress" --> doFloat
  358. , className =? "dialog" --> doFloat
  359. , className =? "download" --> doFloat
  360. , className =? "error" --> doFloat
  361. , className =? "Gimp" --> doFloat
  362. , className =? "notification" --> doFloat
  363. , className =? "pinentry-gtk-2" --> doFloat
  364. , className =? "splash" --> doFloat
  365. , className =? "toolbar" --> doFloat
  366. , className =? "Yad" --> doCenterFloat
  367. , title =? "Mozilla Firefox" --> doShift ( myWorkspaces !! 0 )
  368. , title =? "Mozilla Thunderbird" --> doShift ( myWorkspaces !! 3 )
  369. , className =? "Evolution" --> doShift ( myWorkspaces !! 3 )
  370. , className =? "emacs" --> doShift ( myWorkspaces !! 2 )
  371. , className =? "mpv" --> doShift ( myWorkspaces !! 5 )
  372. , className =? "pcmanfm" --> doShift ( myWorkspaces !! 2 )
  373. , (className =? "firefox" <&&> resource =? "Dialog") --> doFloat -- Float Firefox Dialog
  374. , (className =? "evolution" <&&> resource =? "Dialog") --> doFloat -- Float Firefox Dialog
  375. , isFullscreen --> doFullFloat
  376. ] <+> namedScratchpadManageHook myScratchPads
  377.  
  378. -- START_KEYS
  379. myKeys :: [(String, X ())]
  380. myKeys =
  381. -- KB_GROUP Xmonad
  382. [ ("M-S-l", spawn "xmonad --recompile") -- Recompiles xmonad
  383. , ("M-S-r", spawn "xmonad --restart") -- Restarts xmonad
  384. , ("M-S-q", io exitSuccess) -- Quits xmonad
  385. , ("M-S-/", spawn "sh ~/.xmonad/xmonad_keys.sh")
  386.  
  387. -- KB_GROUP Run Prompt
  388. , ("M-S-<Return>", spawn "rofi -show drun")
  389.  
  390. -- KB_GROUP Useful programs to have a keybinding for launch
  391. , ("M-<Return>", spawn (myTerminal))
  392. , ("M-b", spawn (myBrowser))
  393. , ("M-m", spawn (myMail))
  394. , ("M-f", spawn (myFiles))
  395.  
  396. -- KB_GROUP Kill windows
  397. -- , ("M-S-c", kill1) -- Kill the currently focused client
  398. -- , ("M-S-a", killAll) -- Kill all windows on current workspace
  399.  
  400. -- KB_GROUP Workspaces
  401. , ("M-,", nextScreen) -- Switch focus to next monitor
  402. , ("M-.", prevScreen) -- Switch focus to prev monitor
  403. , ("M-S-.", shiftTo Next nonNSP >> moveTo Next nonNSP) -- Shifts focused window to next ws
  404. , ("M-S-,", shiftTo Prev nonNSP >> moveTo Prev nonNSP) -- Shifts focused window to prev ws
  405. , ("C-,", shiftNextScreen >> nextScreen) -- Shifts focused windew to prev ws
  406. , ("C-.", shiftPrevScreen >> prevScreen) -- Shifts focused windew to prev ws
  407.  
  408. -- KB_GROUP Floating windows
  409. , ("M-f", sendMessage (T.Toggle "floats")) -- Toggles my 'floats' layout
  410. , ("M-t", withFocused $ windows . W.sink) -- Push floating window back to tile
  411. , ("M-S-t", sinkAll) -- Push ALL floating windows to tile
  412.  
  413. -- KB_GROUP Increase/decrease spacing (gaps)
  414. , ("C-M1-h", decWindowSpacing 4) -- Decrease window spacing
  415. , ("C-M1-t", incWindowSpacing 4) -- Increase window spacing
  416. , ("C-M1-d", decScreenSpacing 4) -- Decrease screen spacing
  417. , ("C-M1-n", incScreenSpacing 4) -- Increase screen spacing
  418.  
  419. -- KB_GROUP Grid Select (CTR-g followed by a key)
  420. , ("C-g g", spawnSelected' myAppGrid) -- grid select favorite apps
  421. , ("C-g t", goToSelected $ mygridConfig myColorizer) -- goto selected window
  422. , ("C-g b", bringSelected $ mygridConfig myColorizer) -- bring selected window
  423.  
  424. -- KB_GROUP Windows navigation
  425. , ("M-'", windows W.focusMaster) -- Move focus to the master window
  426. , ("M-o", windows W.focusDown) -- Move focus to the next window
  427. , ("M-a", windows W.focusUp) -- Move focus to the prev window
  428. , ("M-S-'", windows W.swapMaster) -- Swap the focused window and the master window
  429. , ("M-S-o", windows W.swapDown) -- Swap focused window with next window
  430. , ("M-S-a", windows W.swapUp) -- Swap focused window with prev window
  431. , ("M-<Backspace>", promote) -- Moves focused window to master, others maintain order
  432. , ("M-S-<Tab>", rotSlavesDown) -- Rotate all windows except master and keep focus in place
  433. , ("M-C-<Tab>", rotAllDown) -- Rotate all the windows in the current stack
  434.  
  435. -- KB_GROUP Layouts
  436. , ("M-<Tab>", sendMessage NextLayout) -- Switch to next layout
  437. , ("M-<Space>", sendMessage (MT.Toggle NBFULL) >> sendMessage ToggleStruts) -- Toggles noborder/full
  438.  
  439. -- KB_GROUP Increase/decrease windows in the master pane or the stack
  440. , ("M-S-<Up>", sendMessage (IncMasterN 1)) -- Increase # of clients master pane
  441. , ("M-S-<Down>", sendMessage (IncMasterN (-1))) -- Decrease # of clients master pane
  442. , ("M-C-<Up>", increaseLimit) -- Increase # of windows
  443. , ("M-C-<Down>", decreaseLimit) -- Decrease # of windows
  444.  
  445. -- KB_GROUP Window resizing
  446. , ("M-p", sendMessage Shrink) -- Shrink horiz window width
  447. , ("M-y", sendMessage Expand) -- Expand horiz window width
  448. , ("M-M1-h", sendMessage MirrorShrink) -- Shrink vert window width
  449. , ("M-M1-t", sendMessage MirrorExpand) -- Expand vert window width
  450.  
  451. -- KB_GROUP Sublayouts
  452. -- This is used to push windows to tabbed sublayouts, or pull them out of it.
  453. , ("M-C-d", sendMessage $ pullGroup L)
  454. , ("M-C-n", sendMessage $ pullGroup R)
  455. , ("M-C-t", sendMessage $ pullGroup U)
  456. , ("M-C-h", sendMessage $ pullGroup D)
  457. , ("M-C-m", withFocused (sendMessage . MergeAll))
  458. -- , ("M-C-u", withFocused (sendMessage . UnMerge))
  459. , ("M-C-/", withFocused (sendMessage . UnMergeAll))
  460. , ("M-C-,", onGroup W.focusUp') -- Switch focus to next tab
  461. , ("M-C-.", onGroup W.focusDown') -- Switch focus to prev tab
  462.  
  463. -- KB_GROUP Scratchpads
  464. -- Toggle show/hide these programs. They run on a hidden workspace.
  465. -- When you toggle them to show, it brings them to your current workspace.
  466. -- Toggle them to hide and it sends them back to hidden workspace (NSP).
  467. -- , ("M-s t", namedScratchpadAction myScratchPads "terminal")
  468. -- , ("M-s m", namedScratchpadAction myScratchPads "mocp")
  469. -- , ("M-s c", namedScratchpadAction myScratchPads "calculator")
  470.  
  471. -- KB_GROUP Set wallpaper
  472. -- Set wallpaper with either 'xwallwaper'. Type 'SUPER+F1' to launch sxiv in the
  473. -- wallpapers directory; then in sxiv, type 'C-x x' to set the wallpaper that you
  474. -- choose. Or, type 'SUPER+F2' to set a random wallpaper.
  475. , ("M-<F1>", spawn "find /home/pascal/Pictures/wallpapers -type f | shuf -n 1 | xargs xwallpaper --output HDMI-A-0 --stretch")
  476. , ("M-<F2>", spawn "find /home/pascal/Pictures/wallpapers -type f | shuf -n 1 | xargs xwallpaper --output DVI-D-1 --stretch")
  477. , ("M-<F3>", spawn "find /home/pascal/Pictures/wallpapers -type f | shuf -n 1 | xargs xwallpaper --output DVI-D-0 --stretch")
  478.  
  479. -- KB_GROUP Emacs (CTRL-e followed by a key)
  480. , ("C-e e", spawn (myEmacs)) -- emacs
  481. -- , ("C-e b", spawn (myEmacs ++ ("--eval '(ibuffer)'"))) -- list buffers
  482. -- , ("C-e d", spawn (myEmacs ++ ("--eval '(dired nil)'"))) -- dired
  483. -- , ("C-e i", spawn (myEmacs ++ ("--eval '(erc)'"))) -- erc irc client
  484. -- , ("C-e n", spawn (myEmacs ++ ("--eval '(elfeed)'"))) -- elfeed rss
  485. -- , ("C-e s", spawn (myEmacs ++ ("--eval '(eshell)'"))) -- eshell
  486. -- , ("C-e t", spawn (myEmacs ++ ("--eval '(mastodon)'"))) -- mastodon.el
  487. -- , ("C-e v", spawn (myEmacs ++ ("--eval '(+vterm/here nil)'"))) -- vterm if on Doom Emacs
  488. -- , ("C-e w", spawn (myEmacs ++ ("--eval '(doom/window-maximize-buffer(eww \"distrotube.com\"))'"))) -- eww browser if on Doom Emacs
  489. -- , ("C-e a", spawn (myEmacs ++ ("--eval '(emms)' --eval '(emms-play-directory-tree \"~/Music/\")'")))
  490. ]
  491.  
  492. -- The following lines are needed for named scratchpads.
  493. where nonNSP = WSIs (return (\ws -> W.tag ws /= "NSP"))
  494. nonEmptyNonNSP = WSIs (return (\ws -> isJust (W.stack ws) && W.tag ws /= "NSP"))
  495. -- END_KEYS
  496.  
  497. myIcons :: Query [String]
  498. myIcons = composeAll
  499. [-- className =? "Firefox" --> appIcon "<fn=5>\xe745</fn>"
  500. --, className =? "Emacs" --> appIcon "<fn=5>\xe7cf</fn>"
  501. className =? "Alacritty" --> appIcon "<fn=5>\xe795</fn>"
  502. --, className =? "Pcmanfm" --> appIcon "<fn=5>\xe5fe</fn>"
  503. --, className =? "Thunderbird" --> appIcon "<fn=5>\xf370</fn>"
  504. --, className =? "Discord" --> appIcon "<fn=5>\xf1ff</fn>"
  505. ]
  506.  
  507. myIconConfig :: IconConfig
  508. myIconConfig = def { iconConfigIcons = myIcons
  509. , iconConfigFmt = iconsFmtReplace concat
  510. , iconConfigFilter = iconsGetFocus
  511. }
  512.  
  513. myXmobarPP :: PP
  514. myXmobarPP = def
  515. { ppCurrent = xmobarColor "#9ece6a" "#282c34:0" . wrap "<box type=Bottom width=2 mb=2 color=#e0af68>" "</box>" -- Current workspace
  516. , ppVisible = xmobarColor "#9ece6a" "#282c34:0" . clickable -- Visible but not current workspace
  517. , ppHidden = xmobarColor "#7da6ff" "#282c34:0" . wrap "<box type=Top width=2 mt=2 color=#7da6ff>" "</box>" . clickable -- Hidden workspaces
  518. , ppHiddenNoWindows = xmobarColor "#7da6ff" "#282c34:0" . clickable -- Hidden workspaces (no windows)
  519. , ppTitle = xmobarColor "#787c99" "#282c34:0" . shorten 40 -- Title of active window
  520. , ppSep = wrapSep " "
  521. , ppUrgent = xmobarColor "#C45500" "#282c34:0" . wrap "!" "!" -- Urgent workspace
  522. , ppLayout = xmobarColor "#ff6c6b" "#282c34:0" . wrap """"
  523. , ppWsSep = xmobarColor "#282c34" "#282c34:0" " "
  524. -- , ppExtras = [windowCount] -- # of windows current workspace
  525. -- , ppOrder = \(ws:l:t:ex) -> [ws,l]++ex++[t] -- order of things in xmobar
  526. }
  527. where
  528. wrapSep :: String -> String
  529. wrapSep = wrap "<fc=#282c34><fn=4>\xe0b4</fn></fc>""<fc=#282c34><fn=4>\xe0b6</fn></fc>"
  530.  
  531.  
  532. mySBScreenCenter :: StatusBarConfig
  533. mySBScreenCenter = statusBarProp
  534. "xmobar -x 0 $HOME/.config/xmobar/xmobarrc0"
  535. --(clickablePP =<< dynamicIconsPP myIconConfig (filterOutWsPP [scratchpadWorkspaceTag] myXmobarPP))
  536. (iconsPP myIcons (filterOutWsPP [scratchpadWorkspaceTag] myXmobarPP))
  537.  
  538. mySBScreenLeft :: StatusBarConfig
  539. mySBScreenLeft = statusBarProp
  540. "xmobar -x 1 $HOME/.config/xmobar/xmobarrc1"
  541. (iconsPP myIcons (filterOutWsPP [scratchpadWorkspaceTag] myXmobarPP))
  542. --(clickablePP =<< dynamicIconsPP myIconConfig (filterOutWsPP [scratchpadWorkspaceTag] myXmobarPP))
  543.  
  544. main :: IO ()
  545. main = do
  546. -- the xmonad, ya know...what the WM is named after!
  547. xmonad . withSB (mySBScreenCenter <> mySBScreenLeft) . ewmh $ def
  548. { manageHook = manageSpawn <+> myManageHook <+> manageDocks
  549. , handleEventHook = docksEventHook
  550. -- Uncomment this line to enable fullscreen support on things like YouTube/Netflix.
  551. -- This works perfect on SINGLE monitor systems. On multi-monitor systems,
  552. -- it adds a border around the window if screen does not have focus. So, my solution
  553. -- is to use a keybinding to toggle fullscreen noborders instead. (M-<Space>)
  554. -- <+> fullscreenEventHook
  555. , modMask = myModMask
  556. , terminal = myTerminal
  557. , startupHook = myStartupHook
  558. , layoutHook = myLayoutHook -- showWName' myShowWNameTheme
  559. , workspaces = myWorkspaces
  560. , borderWidth = myBorderWidth
  561. , normalBorderColor = myNormColor
  562. , focusedBorderColor = myFocusColor
  563. } `additionalKeysP` myKeys
  564. where
  565. wrapSep :: String -> String
  566. wrapSep = wrap "<fc=#282c34><fn=4>\xe0b4</fn></fc>""<fc=#282c34><fn=4>\xe0b6</fn></fc>"
  567.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement