Guest User

Untitled

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