Advertisement
Guest User

my xmonad.hs

a guest
Nov 3rd, 2012
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Haskell 12.36 KB | None | 0 0
  1. --
  2. -- xmonad example config file for xmonad-0.9
  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. -- NOTE: Those updating from earlier xmonad versions, who use
  10. -- EwmhDesktops, safeSpawn, WindowGo, or the simple-status-bar
  11. -- setup functions (dzen, xmobar) probably need to change
  12. -- xmonad.hs, please see the notes below, or the following
  13. -- link for more details:
  14. --
  15. -- http://www.haskell.org/haskellwiki/Xmonad/Notable_changes_since_0.8
  16. --
  17.  
  18. import XMonad
  19. import Data.Monoid
  20. import System.Exit
  21. import XMonad.Layout.WindowNavigation
  22.  
  23. import XMonad.Layout.Circle
  24.  
  25. import XMonad.Actions.FloatSnap
  26.  
  27. import XMonad.Layout.Maximize
  28. import XMonad.Layout.Dishes
  29.  
  30. import qualified XMonad.StackSet as W
  31. import qualified Data.Map        as M
  32.  
  33. -- The preferred terminal program, which is used in a binding below and by
  34. -- certain contrib modules.
  35. --
  36. myTerminal      = "gnome-terminal"
  37.  
  38. -- Whether focus follows the mouse pointer.
  39. myFocusFollowsMouse :: Bool
  40. myFocusFollowsMouse = True
  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. -- NOTE: from 0.9.1 on numlock mask is set automatically. The numlockMask
  54. -- setting should be removed from configs.
  55. --
  56. -- You can safely remove this even on earlier xmonad versions unless you
  57. -- need to set it to something other than the default mod2Mask, (e.g. OSX).
  58. --
  59. -- The mask for the numlock key. Numlock status is "masked" from the
  60. -- current modifier status, so the keybindings will work with numlock on or
  61. -- off. You may need to change this on some systems.
  62. --
  63. -- You can find the numlock modifier by running "xmodmap" and looking for a
  64. -- modifier with Num_Lock bound to it:
  65. --
  66. -- > $ xmodmap | grep Num
  67. -- > mod2        Num_Lock (0x4d)
  68. --
  69. -- Set numlockMask = 0 if you don't have a numlock key, or want to treat
  70. -- numlock status separately.
  71. --
  72. -- myNumlockMask   = mod2Mask -- deprecated in xmonad-0.9.1
  73. ------------------------------------------------------------
  74.  
  75.  
  76. -- The default number of workspaces (virtual screens) and their names.
  77. -- By default we use numeric strings, but any string may be used as a
  78. -- workspace name. The number of workspaces is determined by the length
  79. -- of this list.
  80. --
  81. -- A tagging example:
  82. --
  83. -- > workspaces = ["web", "irc", "code" ] ++ map show [4..9]
  84. --
  85. myWorkspaces    = ["1","2","3","4","5","6","7","8","9"]
  86.  
  87. -- Border colors for unfocused and focused windows, respectively.
  88. --
  89. myNormalBorderColor  = "#dddddd"
  90. myFocusedBorderColor = "#ff0000"
  91.  
  92. ------------------------------------------------------------------------
  93. -- Key bindings. Add, modify or remove key bindings here.
  94. --
  95. myKeys conf@(XConfig {XMonad.modMask = modm}) = M.fromList $
  96.  
  97.     -- launch a terminal
  98.     [ ((modm .|. shiftMask, xK_Return), spawn $ XMonad.terminal conf)
  99.  
  100.     -- launch dmenu
  101.     , ((modm,               xK_p     ), spawn "exe=`dmenu_path | dmenu` && eval \"exec $exe\"")
  102.  
  103.     -- launch gmrun
  104.     , ((modm .|. shiftMask, xK_p     ), spawn "gmrun")
  105.  
  106.     -- close focused window
  107.     , ((modm .|. shiftMask, xK_c     ), kill)
  108.  
  109.      -- Rotate through the available layout algorithms
  110.     , ((modm,               xK_space ), sendMessage NextLayout)
  111.  
  112.     --  Reset the layouts on the current workspace to default
  113.     , ((modm .|. shiftMask, xK_space ), setLayout $ XMonad.layoutHook conf)
  114.  
  115.     -- Resize viewed windows to the correct size
  116.     --, ((modm,               xK_n     ), refresh)
  117.  
  118.     -- Maximize/Minimize
  119.     --, ((modm, xK_backslash), withFocused (sendMessage . maximizeRestore))
  120.  
  121.     -- Move focus to the next window
  122.     , ((modm,               xK_Tab   ), windows W.focusDown)
  123.  
  124.  
  125.     -- Move focus to the master window
  126.     , ((modm,               xK_m     ), windows W.focusMaster  )
  127.  
  128.     -- Swap the focused window and the master window
  129.     , ((modm,               xK_Return), windows W.swapMaster)
  130.  
  131.  
  132.  
  133.     -- minimize maximize functionality
  134.     , ((modm,               xK_v     ), withFocused (sendMessage . maximizeRestore))
  135.  
  136.     -- sean's test functionality
  137.     --, ((modm .|. shiftMask,               xK_n     ), sendMessage $ Swap U)
  138.     , ((modm .|. shiftMask,                 xK_h     ), sendMessage $ Swap L)
  139.     , ((modm .|. shiftMask, xK_j     ), sendMessage $ Swap D  )
  140.     , ((modm .|. shiftMask, xK_k     ), sendMessage $ Swap U    )
  141.     , ((modm .|. shiftMask, xK_l     ), sendMessage $ Swap R    )
  142.  
  143.     , ((modm,               xK_h     ), sendMessage $ Go L)
  144.     , ((modm,               xK_j     ), sendMessage $ Go D)
  145.     , ((modm,               xK_k     ), sendMessage $ Go U)
  146.     , ((modm,               xK_l     ), sendMessage $ Go R)
  147.  
  148.     -- Push window back into tiling
  149.     , ((modm,               xK_t     ), withFocused $ windows . W.sink)
  150.  
  151.     -- Increment the number of windows in the master area
  152.     , ((modm              , xK_comma ), sendMessage (IncMasterN 1))
  153.  
  154.     -- Deincrement the number of windows in the master area
  155.     , ((modm              , xK_period), sendMessage (IncMasterN (-1)))
  156.  
  157.     -- Toggle the status bar gap
  158.     -- Use this binding with avoidStruts from Hooks.ManageDocks.
  159.     -- See also the statusBar function from Hooks.DynamicLog.
  160.     --
  161.     -- , ((modm              , xK_b     ), sendMessage ToggleStruts)
  162.  
  163.     -- Quit xmonad
  164.     , ((modm .|. shiftMask, xK_q     ), io (exitWith ExitSuccess))
  165.  
  166.     -- Restart xmonad
  167.     , ((modm              , xK_q     ), spawn "xmonad --recompile; xmonad --restart")
  168.     ]
  169.     ++
  170.  
  171.     --
  172.     -- mod-[1..9], Switch to workspace N
  173.     --
  174.     -- mod-[1..9], Switch to workspace N
  175.     -- mod-shift-[1..9], Move client to workspace N
  176.     --
  177.     [((m .|. modm, k), windows $ f i)
  178.         | (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9]
  179.         , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]]
  180.     ++
  181.  
  182.     --
  183.     -- mod-{w,e,r}, Switch to physical/Xinerama screens 1, 2, or 3
  184.     -- mod-shift-{w,e,r}, Move client to screen 1, 2, or 3
  185.     --
  186.     [((m .|. modm, key), screenWorkspace sc >>= flip whenJust (windows . f))
  187.         | (key, sc) <- zip [xK_w, xK_e, xK_r] [0..]
  188.         , (f, m) <- [(W.view, 0), (W.shift, shiftMask)]]
  189.  
  190.  
  191. ------------------------------------------------------------------------
  192. -- Mouse bindings: default actions bound to mouse events
  193. --
  194. myMouseBindings (XConfig {XMonad.modMask = modm}) = M.fromList $
  195.  
  196.     -- mod-button1, Set the window to floating mode and move by dragging
  197.     [ ((modm, button1), (\w -> focus w >> mouseMoveWindow w
  198.                                        >> windows W.shiftMaster))
  199.  
  200.     -- mod-button2, Raise the window to the top of the stack
  201.     , ((modm, button2), (\w -> focus w >> windows W.shiftMaster))
  202.  
  203.     -- mod-button3, Set the window to floating mode and resize by dragging
  204.     , ((modm, button3), (\w -> focus w >> mouseResizeWindow w
  205.                                        >> windows W.shiftMaster))
  206.  
  207.     -- you may also bind events to the mouse scroll wheel (button4 and button5)
  208.     ]
  209.  
  210. ------------------------------------------------------------------------
  211. -- Layouts:
  212.  
  213. -- You can specify and transform your layouts by modifying these values.
  214. -- If you change layout bindings be sure to use 'mod-shift-space' after
  215. -- restarting (with 'mod-q') to reset your layout state to the new
  216. -- defaults, as xmonad preserves your old layout settings by default.
  217. --
  218. -- * NOTE: XMonad.Hooks.EwmhDesktops users must remove the obsolete
  219. -- ewmhDesktopsLayout modifier from layoutHook. It no longer exists.
  220. -- Instead use the 'ewmh' function from that module to modify your
  221. -- defaultConfig as a whole. (See also logHook, handleEventHook, and
  222. -- startupHook ewmh notes.)
  223. --
  224. -- The available layouts.  Note that each layout is separated by |||,
  225. -- which denotes layout choice.
  226. --
  227. myLayout = windowNavigation (maximize tiled) ||| windowNavigation (maximize (Mirror tiled)) ||| Full ||| Circle -- ||| maximize (Tall 1 (3/100) (1/2)) -- ||| Dishes 2 (1/6) --
  228.   where
  229.     -- default tiling algorithm partitions the screen into two panes
  230.     tiled   = Tall nmaster delta ratio
  231.  
  232.     -- The default number of windows in the master pane
  233.     nmaster = 1
  234.  
  235.     -- Default proportion of screen occupied by master pane
  236.     ratio   = 1/2
  237.  
  238.     -- Percent of screen to increment by when resizing panes
  239.     delta   = 3/100
  240.  
  241. ------------------------------------------------------------------------
  242. -- Window rules:
  243.  
  244. -- Execute arbitrary actions and WindowSet manipulations when managing
  245. -- a new window. You can use this to, for example, always float a
  246. -- particular program, or have a client always appear on a particular
  247. -- workspace.
  248. --
  249. -- To find the property name associated with a program, use
  250. -- > xprop | grep WM_CLASS
  251. -- and click on the client you're interested in.
  252. --
  253. -- To match on the WM_NAME, you can use 'title' in the same way that
  254. -- 'className' and 'resource' are used below.
  255. --
  256. myManageHook = composeAll
  257.     [ className =? "MPlayer"        --> doFloat
  258.     , className =? "Gimp"           --> doFloat
  259.     , resource  =? "desktop_window" --> doIgnore
  260.     , resource  =? "kdesktop"       --> doIgnore ]
  261.  
  262. ------------------------------------------------------------------------
  263. -- Event handling
  264.  
  265. -- Defines a custom handler function for X Events. The function should
  266. -- return (All True) if the default handler is to be run afterwards. To
  267. -- combine event hooks use mappend or mconcat from Data.Monoid.
  268. --
  269. -- * NOTE: EwmhDesktops users should use the 'ewmh' function from
  270. -- XMonad.Hooks.EwmhDesktops to modify their defaultConfig as a whole.
  271. -- It will add EWMH event handling to your custom event hooks by
  272. -- combining them with ewmhDesktopsEventHook.
  273. --
  274. myEventHook = mempty
  275.  
  276. ------------------------------------------------------------------------
  277. -- Status bars and logging
  278.  
  279. -- Perform an arbitrary action on each internal state change or X event.
  280. -- See the 'XMonad.Hooks.DynamicLog' extension for examples.
  281. --
  282. --
  283. -- * NOTE: EwmhDesktops users should use the 'ewmh' function from
  284. -- XMonad.Hooks.EwmhDesktops to modify their defaultConfig as a whole.
  285. -- It will add EWMH logHook actions to your custom log hook by
  286. -- combining it with ewmhDesktopsLogHook.
  287. --
  288. myLogHook = return ()
  289.  
  290. ------------------------------------------------------------------------
  291. -- Startup hook
  292.  
  293. -- Perform an arbitrary action each time xmonad starts or is restarted
  294. -- with mod-q.  Used by, e.g., XMonad.Layout.PerWorkspace to initialize
  295. -- per-workspace layout choices.
  296. --
  297. -- By default, do nothing.
  298. --
  299. -- * NOTE: EwmhDesktops users should use the 'ewmh' function from
  300. -- XMonad.Hooks.EwmhDesktops to modify their defaultConfig as a whole.
  301. -- It will add initialization of EWMH support to your custom startup
  302. -- hook by combining it with ewmhDesktopsStartup.
  303. --
  304. myStartupHook = return ()
  305.  
  306. ------------------------------------------------------------------------
  307. -- Now run xmonad with all the defaults we set up.
  308.  
  309. -- Run xmonad with the settings you specify. No need to modify this.
  310. --
  311. main = xmonad defaults
  312.  
  313. -- A structure containing your configuration settings, overriding
  314. -- fields in the default config. Any you don't override, will
  315. -- use the defaults defined in xmonad/XMonad/Config.hs
  316. --
  317. -- No need to modify this.
  318. --
  319. defaults = defaultConfig {
  320.       -- simple stuff
  321.         terminal           = myTerminal,
  322.         focusFollowsMouse  = myFocusFollowsMouse,
  323.         borderWidth        = myBorderWidth,
  324.         modMask            = myModMask,
  325.         -- numlockMask deprecated in 0.9.1
  326.         -- numlockMask        = myNumlockMask,
  327.         workspaces         = myWorkspaces,
  328.         normalBorderColor  = myNormalBorderColor,
  329.         focusedBorderColor = myFocusedBorderColor,
  330.  
  331.       -- key bindings
  332.         keys               = myKeys,
  333.         mouseBindings      = myMouseBindings,
  334.  
  335.       -- hooks, layouts
  336.         layoutHook         = myLayout,
  337.         manageHook         = myManageHook,
  338.         handleEventHook    = myEventHook,
  339.         logHook            = myLogHook,
  340.         startupHook        = myStartupHook
  341.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement