Advertisement
Guest User

xmonad.hs

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