merulox

xmonad.hs

Dec 20th, 2021
333
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.17 KB | None | 0 0
  1. -- IMPORTS
  2.  
  3. import XMonad
  4. import Data.Monoid
  5. import System.Exit
  6. import XMonad.Util.SpawnOnce
  7. import XMonad.Util.Run
  8. import XMonad.Hooks.ManageDocks
  9. import XMonad.Layout.Spacing
  10. import XMonad.Layout.ResizableTile
  11. import qualified XMonad.StackSet as W
  12. import qualified Data.Map as M
  13.  
  14. -- The preferred terminal program, which is used in a binding below and by
  15. -- certain contrib modules.
  16. --
  17. myTerminal = "gnome-terminal"
  18.  
  19. -- Whether focus follows the mouse pointer.
  20. myFocusFollowsMouse :: Bool
  21. myFocusFollowsMouse = True
  22.  
  23. -- Whether clicking on a window to focus also passes the click to the window
  24. myClickJustFocuses :: Bool
  25. myClickJustFocuses = False
  26.  
  27. -- Width of the window border in pixels.
  28. --
  29. myBorderWidth = 2
  30.  
  31. -- modMask lets you specify which modkey you want to use. The default
  32. -- is mod1Mask ("left alt"). You may also consider using mod3Mask
  33. -- ("right alt"), which does not conflict with emacs keybindings. The
  34. -- "windows key" is usually mod4Mask.
  35. --
  36. myModMask = mod1Mask
  37.  
  38. -- The default number of workspaces (virtual screens) and their names.
  39. -- By default we use numeric strings, but any string may be used as a
  40. -- workspace name. The number of workspaces is determined by the length
  41. -- of this list.
  42. --
  43. -- A tagging example:
  44. --
  45. -- > workspaces = ["web", "irc", "code" ] ++ map show [4..9]
  46. --
  47. myWorkspaces = ["1","2","3","4","5","6","7","8","9"]
  48.  
  49. -- Border colors for unfocused and focused windows, respectively.
  50. --
  51. myNormalBorderColor = "#dddddd"
  52. myFocusedBorderColor = "#ff0000"
  53.  
  54. ------------------------------------------------------------------------
  55. -- Key bindings. Add, modify or remove key bindings here.
  56. --
  57. myKeys conf@(XConfig {XMonad.modMask = modm}) = M.fromList $
  58.  
  59. -- launch a terminal
  60. [ ((modm .|. shiftMask, xK_Return), spawn $ XMonad.terminal conf)
  61.  
  62. -- launch dmenu
  63. , ((modm, xK_p ), spawn "dmenu_run")
  64.  
  65. -- launch gmrun
  66. , ((modm .|. shiftMask, xK_p ), spawn "gmrun")
  67.  
  68. -- close focused window
  69. , ((modm .|. shiftMask, xK_c ), kill)
  70.  
  71. -- Rotate through the available layout algorithms
  72. , ((modm, xK_space ), sendMessage NextLayout)
  73.  
  74. -- Reset the layouts on the current workspace to default
  75. , ((modm .|. shiftMask, xK_space ), setLayout $ XMonad.layoutHook conf)
  76.  
  77. -- Resize viewed windows to the correct size
  78. , ((modm, xK_n ), refresh)
  79.  
  80. -- Move focus to the next window
  81. , ((modm, xK_Tab ), windows W.focusDown)
  82.  
  83. -- Move focus to the next window
  84. , ((modm, xK_k ), windows W.focusDown)
  85.  
  86. -- Move focus to the previous window
  87. , ((modm, xK_j ), windows W.focusUp )
  88.  
  89. -- Move focus to the master window
  90. , ((modm, xK_m ), windows W.focusMaster )
  91.  
  92. -- Swap the focused window and the master window
  93. , ((modm, xK_Return), windows W.swapMaster)
  94.  
  95. -- Swap the focused window with the next window
  96. , ((modm .|. shiftMask, xK_k ), windows W.swapDown )
  97.  
  98. -- Swap the focused window with the previous window
  99. , ((modm .|. shiftMask, xK_j ), windows W.swapUp )
  100.  
  101. -- Shrink the master area
  102. , ((modm, xK_h ), sendMessage Shrink)
  103.  
  104. -- Expand the master area
  105. , ((modm, xK_l ), sendMessage Expand)
  106.  
  107. -- Push window back into tiling
  108. , ((modm, xK_t ), withFocused $ windows . W.sink)
  109.  
  110. -- Increment the number of windows in the master area
  111. , ((modm , xK_comma ), sendMessage (IncMasterN 1))
  112.  
  113. -- Deincrement the number of windows in the master area
  114. , ((modm , xK_period), sendMessage (IncMasterN (-1)))
  115.  
  116. -- Toggle the status bar gap
  117. -- Use this binding with avoidStruts from Hooks.ManageDocks.
  118. -- See also the statusBar function from Hooks.DynamicLog.
  119. --
  120. -- , ((modm , xK_b ), sendMessage ToggleStruts)
  121.  
  122. -- Quit xmonad
  123. , ((modm .|. shiftMask, xK_q ), io (exitWith ExitSuccess))
  124.  
  125. -- Restart xmonad
  126. , ((modm , xK_q ), spawn "xmonad --recompile; xmonad --restart")
  127.  
  128. -- Run xmessage with a summary of the default keybindings (useful for beginners)
  129. , ((modm .|. shiftMask, xK_slash ), spawn ("echo \"" ++ help ++ "\" | xmessage -file -"))
  130. ]
  131. ++
  132.  
  133. --
  134. -- mod-[1..9], Switch to workspace N
  135. -- mod-shift-[1..9], Move client to workspace N
  136. --
  137. [((m .|. modm, k), windows $ f i)
  138. | (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9]
  139. , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]]
  140. ++
  141.  
  142. --
  143. -- mod-{w,e,r}, Switch to physical/Xinerama screens 1, 2, or 3
  144. -- mod-shift-{w,e,r}, Move client to screen 1, 2, or 3
  145. --
  146. [((m .|. modm, key), screenWorkspace sc >>= flip whenJust (windows . f))
  147. | (key, sc) <- zip [xK_w, xK_e, xK_r] [0..]
  148. , (f, m) <- [(W.view, 0), (W.shift, shiftMask)]]
  149.  
  150.  
  151. ------------------------------------------------------------------------
  152. -- Mouse bindings: default actions bound to mouse events
  153. --
  154. myMouseBindings (XConfig {XMonad.modMask = modm}) = M.fromList $
  155.  
  156. -- mod-button1, Set the window to floating mode and move by dragging
  157. [ ((modm, button1), (\w -> focus w >> mouseMoveWindow w
  158. >> windows W.shiftMaster))
  159.  
  160. -- mod-button2, Raise the window to the top of the stack
  161. , ((modm, button2), (\w -> focus w >> windows W.shiftMaster))
  162.  
  163. -- mod-button3, Set the window to floating mode and resize by dragging
  164. , ((modm, button3), (\w -> focus w >> mouseResizeWindow w
  165. >> windows W.shiftMaster))
  166.  
  167. -- you may also bind events to the mouse scroll wheel (button4 and button5)
  168. ]
  169.  
  170. ------------------------------------------------------------------------
  171. -- Layouts:
  172.  
  173. -- You can specify and transform your layouts by modifying these values.
  174. -- If you change layout bindings be sure to use 'mod-shift-space' after
  175. -- restarting (with 'mod-q') to reset your layout state to the new
  176. -- defaults, as xmonad preserves your old layout settings by default.
  177. --
  178. -- The available layouts. Note that each layout is separated by |||,
  179. -- which denotes layout choice.
  180. --
  181.  
  182. myLayout = avoidStruts (tiled ||| Mirror tiled ||| Full )
  183.  
  184. where
  185.  
  186. -- default tiling algorithm partitions the screen into two panes
  187. tiled = spacing 12 $ ResizableTall nmaster delta ratio []
  188.  
  189. -- The default number of windows in the master pane
  190. nmaster = 1
  191.  
  192. -- Default proportion of screen occupied by master pane
  193. ratio = 1/2
  194.  
  195. -- Percent of screen to increment by when resizing panes
  196. delta = 3/100
  197.  
  198. ------------------------------------------------------------------------
  199. -- Window rules:
  200.  
  201. -- Execute arbitrary actions and WindowSet manipulations when managing
  202. -- a new window. You can use this to, for example, always float a
  203. -- particular program, or have a client always appear on a particular
  204. -- workspace.
  205. --
  206. -- To find the property name associated with a program, use
  207. -- > xprop | grep WM_CLASS
  208. -- and click on the client you're interested in.
  209. --
  210. -- To match on the WM_NAME, you can use 'title' in the same way that
  211. -- 'className' and 'resource' are used below.
  212. --
  213. myManageHook = composeAll
  214. [ className =? "MPlayer" --> doFloat
  215. , className =? "Gimp" --> doFloat
  216. , resource =? "desktop_window" --> doIgnore
  217. , resource =? "kdesktop" --> doIgnore ]
  218.  
  219. ------------------------------------------------------------------------
  220. -- Event handling
  221.  
  222. -- * EwmhDesktops users should change this to ewmhDesktopsEventHook
  223. --
  224. -- Defines a custom handler function for X Events. The function should
  225. -- return (All True) if the default handler is to be run afterwards. To
  226. -- combine event hooks use mappend or mconcat from Data.Monoid.
  227. --
  228. myEventHook = mempty
  229.  
  230. ------------------------------------------------------------------------
  231. -- Status bars and logging
  232.  
  233. -- Perform an arbitrary action on each internal state change or X event.
  234. -- See the 'XMonad.Hooks.DynamicLog' extension for examples.
  235. --
  236. myLogHook = return ()
  237.  
  238. ------------------------------------------------------------------------
  239. -- Startup hook
  240.  
  241. -- Perform an arbitrary action each time xmonad starts or is restarted
  242. -- with mod-q. Used by, e.g., XMonad.Layout.PerWorkspace to initialize
  243. -- per-workspace layout choices.
  244. --
  245. -- By default, do nothing.
  246. myStartupHook = do
  247. spawnOnce "nitrogen --restore &"
  248. spawnOnce "compton &"
  249.  
  250. ------------------------------------------------------------------------
  251. -- Now run xmonad with all the defaults we set up.
  252.  
  253. -- Run xmonad with the settings you specify. No need to modify this.
  254. --
  255. main = do
  256. xmonad def { layoutHook = myLayout }
  257. xmproc <- spawnPipe "xmobar -x 0 /home/merulox1/.config/xmobar/xmobar.config"
  258. xmonad $ docks defaults
  259.  
  260. -- A structure containing your configuration settings, overriding
  261. -- fields in the default config. Any you don't override, will
  262. -- use the defaults defined in xmonad/XMonad/Config.hs
  263. --
  264. -- No need to modify this.
  265. --
  266. defaults = def {
  267. -- simple stuff
  268. terminal = myTerminal,
  269. focusFollowsMouse = myFocusFollowsMouse,
  270. clickJustFocuses = myClickJustFocuses,
  271. borderWidth = myBorderWidth,
  272. modMask = myModMask,
  273. workspaces = myWorkspaces,
  274. normalBorderColor = myNormalBorderColor,
  275. focusedBorderColor = myFocusedBorderColor,
  276.  
  277. -- key bindings
  278. keys = myKeys,
  279. mouseBindings = myMouseBindings,
  280.  
  281. -- hooks, layouts
  282. layoutHook = myLayout,
  283. manageHook = myManageHook,
  284. handleEventHook = myEventHook,
  285. logHook = myLogHook,
  286. startupHook = myStartupHook
  287. }
  288.  
  289. -- | Finally, a copy of the default bindings in simple textual tabular format.
  290. help :: String
  291. help = unlines ["The default modifier key is 'alt'. Default keybindings:",
  292. "",
  293. "-- launching and killing programs",
  294. "mod-Shift-Enter Launch xterminal",
  295. "mod-p Launch dmenu",
  296. "mod-Shift-p Launch gmrun",
  297. "mod-Shift-c Close/kill the focused window",
  298. "mod-Space Rotate through the available layout algorithms",
  299. "mod-Shift-Space Reset the layouts on the current workSpace to default",
  300. "mod-n Resize/refresh viewed windows to the correct size",
  301. "",
  302. "-- move focus up or down the window stack",
  303. "mod-Tab Move focus to the next window",
  304. "mod-Shift-Tab Move focus to the previous window",
  305. "mod-j Move focus to the next window",
  306. "mod-k Move focus to the previous window",
  307. "mod-m Move focus to the master window",
  308. "",
  309. "-- modifying the window order",
  310. "mod-Return Swap the focused window and the master window",
  311. "mod-Shift-j Swap the focused window with the next window",
  312. "mod-Shift-k Swap the focused window with the previous window",
  313. "",
  314. "-- resizing the master/slave ratio",
  315. "mod-h Shrink the master area",
  316. "mod-l Expand the master area",
  317. "",
  318. "-- floating layer support",
  319. "mod-t Push window back into tiling; unfloat and re-tile it",
  320. "",
  321. "-- increase or decrease number of windows in the master area",
  322. "mod-comma (mod-,) Increment the number of windows in the master area",
  323. "mod-period (mod-.) Deincrement the number of windows in the master area",
  324. "",
  325. "-- quit, or restart",
  326. "mod-Shift-q Quit xmonad",
  327. "mod-q Restart xmonad",
  328. "mod-[1..9] Switch to workSpace N",
  329. "",
  330. "-- Workspaces & screens",
  331. "mod-Shift-[1..9] Move client to workspace N",
  332. "mod-{w,e,r} Switch to physical/Xinerama screens 1, 2, or 3",
  333. "mod-Shift-{w,e,r} Move client to screen 1, 2, or 3",
  334. "",
  335. "-- Mouse bindings: default actions bound to mouse events",
  336. "mod-button1 Set the window to floating mode and move by dragging",
  337. "mod-button2 Raise the window to the top of the stack",
  338. "mod-button3 Set the window to floating mode and resize by dragging"]
Advertisement
Add Comment
Please, Sign In to add comment