Advertisement
Guest User

Untitled

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