Advertisement
Guest User

xmonad config

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