Guest

ivarref

By: a guest on May 3rd, 2009  |  syntax: Haskell  |  size: 10.10 KB  |  hits: 150  |  expires: Never
download  |  raw  |  embed  |  report abuse
Copied
  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.Hooks.DynamicLog
  11. import XMonad.Hooks.ManageDocks
  12.  
  13. import XMonad
  14. import System.Exit
  15.  
  16.  
  17. import qualified XMonad.StackSet as W
  18. import qualified Data.Map        as M
  19.  
  20. import XMonad.Util.Paste (pasteString)
  21. import XMonad.Util.Paste (sendKey)
  22.  
  23.  
  24. -- The preferred terminal program, which is used in a binding below and by
  25. -- certain contrib modules.
  26. --
  27. myTerminal      = "konsole"
  28.  
  29. -- Width of the window border in pixels.
  30. --
  31. myBorderWidth   = 2
  32.  
  33. -- modMask lets you specify which modkey you want to use. The default
  34. -- is mod1Mask ("left alt").  You may also consider using mod3Mask
  35. -- ("right alt"), which does not conflict with emacs keybindings. The
  36. -- "windows key" is usually mod4Mask.
  37. --
  38. myModMask       = mod1Mask
  39.  
  40. -- The mask for the numlock key. Numlock status is "masked" from the
  41. -- current modifier status, so the keybindings will work with numlock on or
  42. -- off. You may need to change this on some systems.
  43. --
  44. -- You can find the numlock modifier by running "xmodmap" and looking for a
  45. -- modifier with Num_Lock bound to it:
  46. --
  47. -- > $ xmodmap | grep Num
  48. -- > mod2        Num_Lock (0x4d)
  49. --
  50. -- Set numlockMask = 0 if you don't have a numlock key, or want to treat
  51. -- numlock status separately.
  52. --
  53. myNumlockMask   = mod2Mask
  54.  
  55. -- The default number of workspaces (virtual screens) and their names.
  56. -- By default we use numeric strings, but any string may be used as a
  57. -- workspace name. The number of workspaces is determined by the length
  58. -- of this list.
  59. --
  60. -- A tagging example:
  61. --
  62. -- > workspaces = ["web", "irc", "code" ] ++ map show [4..9]
  63. --
  64. myWorkspaces    = ["1","2","3","4","5","6","7","8","9"]
  65.  
  66. -- Border colors for unfocused and focused windows, respectively.
  67. --
  68. myNormalBorderColor  = "#dddddd"
  69. myFocusedBorderColor = "#ff0000"
  70.  
  71. ------------------------------------------------------------------------
  72. -- Key bindings. Add, modify or remove key bindings here.
  73. --
  74. myKeys conf@(XConfig {XMonad.modMask = modm}) = M.fromList $
  75.  
  76.     -- launch a terminal
  77.     [ ((modm .|. shiftMask, xK_Return), spawn $ XMonad.terminal conf)
  78.  
  79.     -- launch dmenu
  80.     , ((modm,               xK_p     ), spawn "exe=`dmenu_path | dmenu` && eval \"exec $exe\"")
  81.     , ((modm,               xK_F6     ), spawn "aumix -v -")
  82.     , ((modm,               xK_F7     ), spawn "aumix -v +")
  83.  
  84.     -- launch gmrun
  85.     , ((modm .|. shiftMask, xK_p     ), spawn "gmrun")
  86.  
  87.     -- close focused window
  88.     , ((modm .|. shiftMask, xK_c     ), kill)
  89.  
  90.      -- Rotate through the available layout algorithms
  91.     , ((modm,               xK_space ), sendMessage NextLayout)
  92.  
  93.     --  Reset the layouts on the current workspace to default
  94.     , ((modm .|. shiftMask, xK_space ), setLayout $ XMonad.layoutHook conf)
  95.  
  96.     -- Resize viewed windows to the correct size
  97.     , ((modm,               xK_n     ), refresh)
  98.  
  99.     -- Move focus to the next window
  100.     , ((modm,               xK_Tab   ), windows W.focusDown)
  101.     --, ((modm,               xK_i   ), windows W.focusDown)
  102.     , ((modm,               xK_i   ), sequence_ [sendKey controlMask xK_c,
  103.                                                  sendKey controlMask xK_p,
  104.                                                  sendKey controlMask xK_j,
  105.                                                  windows W.focusDown])
  106.  
  107.     -- Move focus to the next window
  108.     , ((modm,               xK_j     ), windows W.focusDown)
  109.  
  110.     -- Move focus to the previous window
  111.     , ((modm,               xK_k     ), windows W.focusUp  )
  112.  
  113.     -- Move focus to the master window
  114.     , ((modm,               xK_m     ), windows W.focusMaster  )
  115.  
  116.     -- Swap the focused window and the master window
  117.     , ((modm,               xK_Return), windows W.swapMaster)
  118.  
  119.     -- Swap the focused window with the next window
  120.     , ((modm .|. shiftMask, xK_j     ), windows W.swapDown  )
  121.  
  122.     -- Swap the focused window with the previous window
  123.     , ((modm .|. shiftMask, xK_k     ), windows W.swapUp    )
  124.  
  125.     -- Shrink the master area
  126.     , ((modm,               xK_h     ), sendMessage Shrink)
  127.  
  128.     -- Expand the master area
  129.     , ((modm,               xK_l     ), sendMessage Expand)
  130.  
  131.     -- Push window back into tiling
  132.     , ((modm,               xK_t     ), withFocused $ windows . W.sink)
  133.  
  134.     -- Increment the number of windows in the master area
  135.     , ((modm              , xK_comma ), sendMessage (IncMasterN 1))
  136.  
  137.     -- Deincrement the number of windows in the master area
  138.     , ((modm              , xK_period), sendMessage (IncMasterN (-1)))
  139.  
  140.     -- toggle the status bar gap
  141.     -- TODO, update this binding with avoidStruts , ((modm , xK_b ), sendMessage ToggleStruts)
  142.  
  143.     -- Quit xmonad
  144.     , ((modm .|. shiftMask, xK_q     ), io (exitWith ExitSuccess))
  145.  
  146.     -- Restart xmonad
  147.     , ((modm              , xK_q     ), restart "xmonad" True)
  148.     ]
  149.     ++
  150.  
  151.     --
  152.     -- mod-[1..9], Switch to workspace N
  153.     -- mod-shift-[1..9], Move client to workspace N
  154.     --
  155.     [((m .|. modm, k), windows $ f i)
  156.         | (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9]
  157.         , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]]
  158.     ++
  159.  
  160.     --
  161.     -- mod-{w,e,r}, Switch to physical/Xinerama screens 1, 2, or 3
  162.     -- mod-shift-{w,e,r}, Move client to screen 1, 2, or 3
  163.     --
  164.     [((m .|. modm, key), screenWorkspace sc >>= flip whenJust (windows . f))
  165.         | (key, sc) <- zip [xK_w, xK_e, xK_r] [0..]
  166.         , (f, m) <- [(W.view, 0), (W.shift, shiftMask)]]
  167.  
  168.  
  169. ------------------------------------------------------------------------
  170. -- Mouse bindings: default actions bound to mouse events
  171. --
  172. myMouseBindings (XConfig {XMonad.modMask = modMask}) = M.fromList $
  173.  
  174.     -- mod-button1, Set the window to floating mode and move by dragging
  175.     [ ((modMask, button1), (\w -> focus w >> mouseMoveWindow w))
  176.  
  177.     -- mod-button2, Raise the window to the top of the stack
  178.     , ((modMask, button2), (\w -> focus w >> windows W.swapMaster))
  179.  
  180.     -- mod-button3, Set the window to floating mode and resize by dragging
  181.     , ((modMask, button3), (\w -> focus w >> mouseResizeWindow w))
  182.  
  183.     -- you may also bind events to the mouse scroll wheel (button4 and button5)
  184.     ]
  185.  
  186. ------------------------------------------------------------------------
  187. -- Layouts:
  188.  
  189. -- You can specify and transform your layouts by modifying these values.
  190. -- If you change layout bindings be sure to use 'mod-shift-space' after
  191. -- restarting (with 'mod-q') to reset your layout state to the new
  192. -- defaults, as xmonad preserves your old layout settings by default.
  193. --
  194. -- The available layouts.  Note that each layout is separated by |||,
  195. -- which denotes layout choice.
  196. --
  197. --myLayout = tiled ||| Mirror tiled ||| Full
  198.  
  199.  
  200. myLayout = avoidStruts (tiled ||| Mirror tiled ||| Full) ||| Full
  201.   where
  202.      -- default tiling algorithm partitions the screen into two panes
  203.      tiled   = Tall nmaster delta ratio
  204.  
  205.      -- The default number of windows in the master pane
  206.      nmaster = 1
  207.  
  208.      -- Default proportion of screen occupied by master pane
  209.      ratio   = 1/2
  210.  
  211.      -- Percent of screen to increment by when resizing panes
  212.      delta   = 3/100
  213.  
  214. ------------------------------------------------------------------------
  215. -- Window rules:
  216.  
  217. -- Execute arbitrary actions and WindowSet manipulations when managing
  218. -- a new window. You can use this to, for example, always float a
  219. -- particular program, or have a client always appear on a particular
  220. -- workspace.
  221. --
  222. -- To find the property name associated with a program, use
  223. -- > xprop | grep WM_CLASS
  224. -- and click on the client you're interested in.
  225. --
  226. -- To match on the WM_NAME, you can use 'title' in the same way that
  227. -- 'className' and 'resource' are used below.
  228. --
  229. myManageHook = composeAll
  230.     [ className =? "MPlayer"        --> doFloat
  231.     , className =? "Gimp"           --> doFloat
  232.     , resource  =? "desktop_window" --> doIgnore
  233.     , resource  =? "kdesktop"       --> doIgnore ]
  234.  
  235. -- Whether focus follows the mouse pointer.
  236. myFocusFollowsMouse :: Bool
  237. myFocusFollowsMouse = True
  238.  
  239.  
  240. ------------------------------------------------------------------------
  241. -- Status bars and logging
  242.  
  243. -- Perform an arbitrary action on each internal state change or X event.
  244. -- See the 'DynamicLog' extension for examples.
  245. --
  246. -- To emulate dwm's status bar
  247. --
  248. -- > logHook = dynamicLogDzen
  249. --
  250. --myLogHook = return ()
  251. --myLogHook = dynamicLogDzen
  252.  
  253. ------------------------------------------------------------------------
  254. -- Startup hook
  255.  
  256. -- Perform an arbitrary action each time xmonad starts or is restarted
  257. -- with mod-q.  Used by, e.g., XMonad.Layout.PerWorkspace to initialize
  258. -- per-workspace layout choices.
  259. --
  260. -- By default, do nothing.
  261. myStartupHook = return ()
  262.  
  263. ------------------------------------------------------------------------
  264. -- Now run xmonad with all the defaults we set up.
  265.  
  266. -- Run xmonad with the settings you specify. No need to modify this.
  267. --
  268. main = xmonad defaults
  269.  
  270. -- A structure containing your configuration settings, overriding
  271. -- fields in the default config. Any you don't override, will
  272. -- use the defaults defined in xmonad/XMonad/Config.hs
  273. --
  274. -- No need to modify this.
  275. --
  276. defaults = defaultConfig {
  277.       -- simple stuff
  278.         terminal           = myTerminal,
  279.         focusFollowsMouse  = myFocusFollowsMouse,
  280.         borderWidth        = myBorderWidth,
  281.         modMask            = myModMask,
  282.         numlockMask        = myNumlockMask,
  283.         workspaces         = myWorkspaces,
  284.         normalBorderColor  = myNormalBorderColor,
  285.         focusedBorderColor = myFocusedBorderColor,
  286.  
  287.       -- key bindings
  288.         keys               = myKeys,
  289.         mouseBindings      = myMouseBindings,
  290.  
  291.       -- hooks, layouts
  292.         layoutHook         = myLayout,
  293.         manageHook         = myManageHook,
  294.         --logHook            = myLogHook,
  295.         startupHook        = myStartupHook
  296.     }