Advertisement
mikelieman

xmonad.hs

Feb 1st, 2013
363
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import XMonad
  2. import XMonad.Hooks.DynamicLog
  3. import XMonad.Hooks.ManageHelpers
  4. import XMonad.Hooks.FadeInactive
  5. import XMonad.Layout.Monitor
  6. import XMonad.Layout.LayoutModifier
  7. import Data.Monoid
  8. import System.Exit
  9.  
  10. import qualified XMonad.StackSet as W
  11. import qualified Data.Map        as M
  12.  
  13. myTerminal      = "xterm -e tmux"
  14.  
  15. myFocusFollowsMouse :: Bool
  16. myFocusFollowsMouse = True
  17.  
  18. myBorderWidth   = 0
  19.  
  20. myModMask       = mod1Mask
  21.  
  22. myWorkspaces    = ["1","2","3","4","5","6","7","8","9"]
  23.  
  24. myNormalBorderColor  = "#dddddd"
  25. myFocusedBorderColor = "#ff0000"
  26.  
  27. myKeys conf@(XConfig {XMonad.modMask = modm}) = M.fromList $
  28.  
  29.     [ ((modm .|. shiftMask, xK_Return), spawn $ XMonad.terminal conf)
  30.  
  31.     , ((modm,               xK_p     ), spawn "exe=`dmenu_path | dmenu_run` && eval \"exec $exe\"")
  32.  
  33.     , ((modm .|. shiftMask, xK_p     ), spawn "gmrun")
  34.  
  35.     , ((modm .|. shiftMask, xK_c     ), kill)
  36.  
  37.     , ((modm,               xK_space ), sendMessage NextLayout)
  38.  
  39.     , ((modm .|. shiftMask, xK_space ), setLayout $ XMonad.layoutHook conf)
  40.  
  41.     , ((modm,               xK_n     ), refresh)
  42.  
  43.     , ((modm,               xK_Tab   ), windows W.focusDown)
  44.  
  45.     , ((modm,               xK_j     ), windows W.focusDown)
  46.  
  47.     , ((modm,               xK_k     ), windows W.focusUp  )
  48.  
  49.     , ((modm,               xK_m     ), windows W.focusMaster  )
  50.  
  51.     , ((modm,               xK_Return), windows W.swapMaster)
  52.  
  53.     , ((modm .|. shiftMask, xK_j     ), windows W.swapDown  )
  54.  
  55.     , ((modm .|. shiftMask, xK_k     ), windows W.swapUp    )
  56.  
  57.     , ((modm,               xK_h     ), sendMessage Shrink)
  58.  
  59.     , ((modm,               xK_l     ), sendMessage Expand)
  60.  
  61.     , ((modm,               xK_t     ), withFocused $ windows . W.sink)
  62.  
  63.     , ((modm              , xK_comma ), sendMessage (IncMasterN 1))
  64.  
  65.     , ((modm              , xK_period), sendMessage (IncMasterN (-1)))
  66.  
  67.     --
  68.  
  69.     , ((modm .|. shiftMask, xK_q     ), io (exitWith ExitSuccess))
  70.  
  71.     , ((modm              , xK_q     ), spawn "xmonad --recompile; xmonad --restart")
  72.     ]
  73.     ++
  74.  
  75.     --
  76.     [((m .|. modm, k), windows $ f i)
  77.         | (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9]
  78.         , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]]
  79.     ++
  80.  
  81.     --
  82.     [((m .|. modm, key), screenWorkspace sc >>= flip whenJust (windows . f))
  83.         | (key, sc) <- zip [xK_w, xK_e, xK_r] [0..]
  84.         , (f, m) <- [(W.view, 0), (W.shift, shiftMask)]]
  85.  
  86. myMouseBindings (XConfig {XMonad.modMask = modm}) = M.fromList $
  87.  
  88.     [ ((modm, button1), (\w -> focus w >> mouseMoveWindow w
  89.                                        >> windows W.shiftMaster))
  90.  
  91.     , ((modm, button2), (\w -> focus w >> windows W.shiftMaster))
  92.  
  93.     , ((modm, button3), (\w -> focus w >> mouseResizeWindow w
  94.                                        >> windows W.shiftMaster))
  95.  
  96.     ]
  97.  
  98. myLayout = tiled ||| Mirror tiled ||| Full
  99.   where
  100.      tiled   = Tall nmaster delta ratio
  101.  
  102.      nmaster = 1
  103.  
  104.      ratio   = 1/2
  105.  
  106.      delta   = 3/100
  107.  
  108. myManageHook = composeAll
  109.     [ className =? "MPlayer"        --> doFloat
  110.     , className =? "Gimp"           --> doFloat
  111.         , (className =? "Firefox" <&&> resource =? "Dialog") --> doFloat
  112.     , className =? "Cairo-dock"     --> doIgnore
  113.     , resource  =? "desktop_window" --> doIgnore
  114.     , resource  =? "kdesktop"       --> doIgnore
  115.         , (isFullscreen --> doFullFloat) ]
  116.  
  117. myEventHook = mempty
  118.  
  119. myLogHook = fadeInactiveLogHook fadeAmount
  120.         where fadeAmount = 0xbbbbbbbb
  121.  
  122. myStartupHook = return ()
  123.  
  124. main = xmonad defaults
  125.  
  126. defaults = defaultConfig {
  127.         terminal           = myTerminal,
  128.         focusFollowsMouse  = myFocusFollowsMouse,
  129.         borderWidth        = myBorderWidth,
  130.         modMask            = myModMask,
  131.         workspaces         = myWorkspaces,
  132.         normalBorderColor  = myNormalBorderColor,
  133.         focusedBorderColor = myFocusedBorderColor,
  134.  
  135.         keys               = myKeys,
  136.         mouseBindings      = myMouseBindings,
  137.  
  138.         layoutHook         = myLayout,
  139.         manageHook         = myManageHook,
  140.         handleEventHook    = myEventHook,
  141.         logHook            = myLogHook,
  142.         startupHook        = myStartupHook
  143.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement