Advertisement
Guest User

sample xmonad.hs

a guest
Nov 30th, 2012
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.Layout.NoBorders
  14.  
  15. import qualified XMonad.StackSet as W
  16. import qualified Data.Map        as M
  17.  
  18. -- The preferred terminal program, which is used in a binding below and by
  19. -- certain contrib modules.
  20. --
  21. myTerminal      = "xterm"
  22.  
  23. -- Whether focus follows the mouse pointer.
  24. myFocusFollowsMouse :: Bool
  25. myFocusFollowsMouse = True
  26.  
  27. -- Width of the window border in pixels.
  28. --
  29. myBorderWidth   = 1
  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_j     ), windows W.focusDown)
  85.  
  86.     -- Move focus to the previous window
  87.     , ((modm,               xK_k     ), 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_j     ), windows W.swapDown  )
  97.  
  98.     -- Swap the focused window with the previous window
  99.     , ((modm .|. shiftMask, xK_k     ), 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.     ++
  129.  
  130.     --
  131.     -- mod-[1..9], Switch to workspace N
  132.     -- mod-shift-[1..9], Move client to workspace N
  133.     --
  134.     [((m .|. modm, k), windows $ f i)
  135.         | (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9]
  136.         , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]]
  137.     ++
  138.  
  139.     --
  140.     -- mod-{w,e,r}, Switch to physical/Xinerama screens 1, 2, or 3
  141.     -- mod-shift-{w,e,r}, Move client to screen 1, 2, or 3
  142.     --
  143.     [((m .|. modm, key), screenWorkspace sc >>= flip whenJust (windows . f))
  144.         | (key, sc) <- zip [xK_w, xK_e, xK_r] [0..]
  145.         , (f, m) <- [(W.view, 0), (W.shift, shiftMask)]]
  146.  
  147.  
  148. ------------------------------------------------------------------------
  149. -- Mouse bindings: default actions bound to mouse events
  150. --
  151. myMouseBindings (XConfig {XMonad.modMask = modm}) = M.fromList $
  152.  
  153.     -- mod-button1, Set the window to floating mode and move by dragging
  154.     [ ((modm, button1), (\w -> focus w >> mouseMoveWindow w
  155.                                        >> windows W.shiftMaster))
  156.  
  157.     -- mod-button2, Raise the window to the top of the stack
  158.     , ((modm, button2), (\w -> focus w >> windows W.shiftMaster))
  159.  
  160.     -- mod-button3, Set the window to floating mode and resize by dragging
  161.     , ((modm, button3), (\w -> focus w >> mouseResizeWindow w
  162.                                        >> windows W.shiftMaster))
  163.  
  164.     -- you may also bind events to the mouse scroll wheel (button4 and button5)
  165.     ]
  166.  
  167. ------------------------------------------------------------------------
  168. -- Layouts:
  169.  
  170. -- You can specify and transform your layouts by modifying these values.
  171. -- If you change layout bindings be sure to use 'mod-shift-space' after
  172. -- restarting (with 'mod-q') to reset your layout state to the new
  173. -- defaults, as xmonad preserves your old layout settings by default.
  174. --
  175. -- The available layouts.  Note that each layout is separated by |||,
  176. -- which denotes layout choice.
  177. --
  178. myLayout = smartBorders $ tiled ||| Mirror tiled ||| Full
  179.   where
  180.      -- default tiling algorithm partitions the screen into two panes
  181.      tiled   = Tall nmaster delta ratio
  182.  
  183.      -- The default number of windows in the master pane
  184.      nmaster = 1
  185.  
  186.      -- Default proportion of screen occupied by master pane
  187.      ratio   = 1/2
  188.  
  189.      -- Percent of screen to increment by when resizing panes
  190.      delta   = 3/100
  191.  
  192. ------------------------------------------------------------------------
  193. -- Window rules:
  194.  
  195. -- Execute arbitrary actions and WindowSet manipulations when managing
  196. -- a new window. You can use this to, for example, always float a
  197. -- particular program, or have a client always appear on a particular
  198. -- workspace.
  199. --
  200. -- To find the property name associated with a program, use
  201. -- > xprop | grep WM_CLASS
  202. -- and click on the client you're interested in.
  203. --
  204. -- To match on the WM_NAME, you can use 'title' in the same way that
  205. -- 'className' and 'resource' are used below.
  206. --
  207. myManageHook = composeAll
  208.     [ className =? "MPlayer"        --> doFloat
  209.     , className =? "Gimp"           --> doFloat
  210.     , resource  =? "desktop_window" --> doIgnore
  211.     , resource  =? "kdesktop"       --> doIgnore ]
  212.  
  213. ------------------------------------------------------------------------
  214. -- Event handling
  215.  
  216. -- * EwmhDesktops users should change this to ewmhDesktopsEventHook
  217. --
  218. -- Defines a custom handler function for X Events. The function should
  219. -- return (All True) if the default handler is to be run afterwards. To
  220. -- combine event hooks use mappend or mconcat from Data.Monoid.
  221. --
  222. myEventHook = mempty
  223.  
  224. ------------------------------------------------------------------------
  225. -- Status bars and logging
  226.  
  227. -- Perform an arbitrary action on each internal state change or X event.
  228. -- See the 'XMonad.Hooks.DynamicLog' extension for examples.
  229. --
  230. myLogHook = return ()
  231.  
  232. ------------------------------------------------------------------------
  233. -- Startup hook
  234.  
  235. -- Perform an arbitrary action each time xmonad starts or is restarted
  236. -- with mod-q.  Used by, e.g., XMonad.Layout.PerWorkspace to initialize
  237. -- per-workspace layout choices.
  238. --
  239. -- By default, do nothing.
  240. myStartupHook = return ()
  241.  
  242. ------------------------------------------------------------------------
  243. -- Now run xmonad with all the defaults we set up.
  244.  
  245. -- Run xmonad with the settings you specify. No need to modify this.
  246. --
  247. main = xmonad defaults
  248.  
  249. -- A structure containing your configuration settings, overriding
  250. -- fields in the default config. Any you don't override, will
  251. -- use the defaults defined in xmonad/XMonad/Config.hs
  252. --
  253. -- No need to modify this.
  254. --
  255. defaults = defaultConfig {
  256.       -- simple stuff
  257.         terminal           = myTerminal,
  258.         focusFollowsMouse  = myFocusFollowsMouse,
  259.         borderWidth        = myBorderWidth,
  260.         modMask            = myModMask,
  261.         workspaces         = myWorkspaces,
  262.         normalBorderColor  = myNormalBorderColor,
  263.         focusedBorderColor = myFocusedBorderColor,
  264.  
  265.       -- key bindings
  266.         keys               = myKeys,
  267.         mouseBindings      = myMouseBindings,
  268.  
  269.       -- hooks, layouts
  270.         layoutHook         = myLayout,
  271.         manageHook         = myManageHook,
  272.         handleEventHook    = myEventHook,
  273.         logHook            = myLogHook,
  274.         startupHook        = myStartupHook
  275.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement