Advertisement
Guest User

xmonad.hs

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