Advertisement
krax

BEST xmonad.hs

Sep 23rd, 2011
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -------------------------------------------------------------------------------
  2. -- xmonad.hs for xmonad-darcs
  3. -- Author: Øyvind 'Mr.Elendig' Heggstad <mrelendig AT har-ikkje DOT net>
  4. -------------------------------------------------------------------------------
  5. -- Compiler flags --
  6. {-# LANGUAGE NoMonomorphismRestriction #-}
  7.  
  8. -- Imports --
  9. -- stuff
  10. import XMonad
  11. import qualified XMonad.StackSet as W
  12. import qualified Data.Map as M
  13. import System.Exit
  14.  
  15. -- actions
  16. import XMonad.Actions.GridSelect
  17.  
  18. -- hooks
  19. import XMonad.Hooks.DynamicLog
  20. import XMonad.Hooks.ManageHelpers
  21. import XMonad.Hooks.UrgencyHook
  22. import XMonad.Hooks.InsertPosition
  23.  
  24. -- layouts
  25. import XMonad.Layout.NoBorders
  26. import XMonad.Layout.ResizableTile
  27. import XMonad.Layout.Named
  28. import XMonad.Layout.Tabbed
  29.  
  30. -------------------------------------------------------------------------------
  31. -- Main --
  32. main :: IO ()
  33. main = xmonad =<< statusBar cmd pp kb conf
  34.   where
  35.     uhook = withUrgencyHookC NoUrgencyHook urgentConfig
  36.     cmd = "bash -c \"tee >(xmobar -x0) | xmobar -x1\""
  37.     pp = customPP
  38.     kb = toggleStrutsKey
  39.     conf = uhook myConfig
  40.  
  41. -------------------------------------------------------------------------------
  42. -- Configs --
  43. myConfig = defaultConfig { workspaces = workspaces'
  44.                         , modMask = modMask'
  45.                          , borderWidth = borderWidth'
  46.                         , normalBorderColor = normalBorderColor'
  47.                          , focusedBorderColor = focusedBorderColor'
  48.                         , terminal = terminal'
  49.                          , keys = keys'
  50.                         , layoutHook = layoutHook'
  51.                          , manageHook = manageHook'
  52.                         }
  53.  
  54. -------------------------------------------------------------------------------
  55. -- Window Management --
  56. manageHook' = composeAll [ isFullscreen             --> doFullFloat
  57.                          , className =? "MPlayer"   --> doFloat
  58.                          , className =? "Gimp"      --> doFloat
  59.                          , className =? "Vlc"       --> doFloat
  60.              , insertPosition Below Newer
  61.              , transience'
  62.                         ]
  63.  
  64.  
  65. -------------------------------------------------------------------------------
  66. -- Looks --
  67. -- bar
  68. customPP = defaultPP { ppCurrent = xmobarColor "#429942" "" . wrap "<" ">"
  69.                     , ppHidden = xmobarColor "#C98F0A" ""
  70.                     , ppHiddenNoWindows = xmobarColor "#C9A34E" ""
  71.                     , ppUrgent = xmobarColor "#FFFFAF" "" . wrap "[" "]"
  72.                     , ppLayout = xmobarColor "#C9A34E" ""
  73.                     , ppTitle =  xmobarColor "#C9A34E" "" . shorten 80
  74.                     , ppSep = xmobarColor "#429942" "" " | "
  75.                     }
  76. -- GridSelect
  77. myGSConfig = defaultGSConfig { gs_cellwidth = 160 }
  78.  
  79. -- urgent notification
  80. urgentConfig = UrgencyConfig { suppressWhen = Focused, remindWhen = Dont }
  81.  
  82. -- borders
  83. borderWidth' = 1
  84. normalBorderColor'  = "#333333"
  85. focusedBorderColor' = "#AFAF87"
  86.  
  87. -- tabs
  88. tabTheme1 = defaultTheme { decoHeight = 16
  89.                          , activeColor = "#a6c292"
  90.                          , activeBorderColor = "#a6c292"
  91.                          , activeTextColor = "#000000"
  92.                          , inactiveBorderColor = "#000000"
  93.                          }
  94.  
  95. -- workspaces
  96. workspaces' = ["1-main", "2-web", "3-mail", "4-torrents", "5-im", "6", "7", "8", "9"]
  97.  
  98. -- layouts
  99. layoutHook' = tile ||| mtile ||| tab ||| full
  100.   where
  101.     rt = ResizableTall 1 (2/100) (1/2) []
  102.     tile = named "[]=" $ smartBorders rt
  103.     mtile = named "M[]=" $ smartBorders $ Mirror rt
  104.     tab = named "T" $ noBorders $ tabbed shrinkText tabTheme1
  105.     full = named "[]" $ noBorders Full
  106.  
  107. -------------------------------------------------------------------------------
  108. -- Terminal --
  109. terminal' = "urxvt"
  110.  
  111. -------------------------------------------------------------------------------
  112. -- Keys/Button bindings --
  113. -- modmask
  114. modMask' = mod4Mask
  115.  
  116. -- keys
  117. toggleStrutsKey :: XConfig Layout -> (KeyMask, KeySym)
  118. toggleStrutsKey XConfig {XMonad.modMask = modMask} = (modMask, xK_b)
  119.  
  120. keys' :: XConfig Layout -> M.Map (KeyMask, KeySym) (X ())
  121. keys' conf@(XConfig {XMonad.modMask = modMask}) = M.fromList $
  122.     -- launching and killing programs
  123.     [ ((modMask,               xK_Return), spawn $ XMonad.terminal conf)
  124.     , ((modMask,               xK_p     ), spawn "dmenu_run")
  125.     , ((modMask .|. shiftMask, xK_p     ), spawn "gmrun")
  126.     , ((modMask .|. shiftMask, xK_m     ), spawn "claws-mail")
  127.     , ((modMask .|. shiftMask, xK_c     ), kill)
  128.  
  129.     -- grid
  130.     , ((modMask,               xK_g     ), goToSelected myGSConfig)
  131.  
  132.     -- layouts
  133.     , ((modMask,               xK_space ), sendMessage NextLayout)
  134.     , ((modMask .|. shiftMask, xK_space ), setLayout $ XMonad.layoutHook conf)
  135.  
  136.     -- floating layer stuff
  137.     , ((modMask,               xK_t     ), withFocused $ windows . W.sink)
  138.  
  139.     -- refresh
  140.     , ((modMask,               xK_n     ), refresh)
  141.  
  142.     -- focus
  143.     , ((modMask,               xK_Tab   ), windows W.focusDown)
  144.     , ((modMask,               xK_j     ), windows W.focusDown)
  145.     , ((modMask,               xK_k     ), windows W.focusUp)
  146.     , ((modMask,               xK_m     ), windows W.focusMaster)
  147.  
  148.     -- swapping
  149.     , ((modMask .|. shiftMask, xK_Return), windows W.swapMaster)
  150.     , ((modMask .|. shiftMask, xK_j     ), windows W.swapDown  )
  151.     , ((modMask .|. shiftMask, xK_k     ), windows W.swapUp    )
  152.  
  153.     -- increase or decrease number of windows in the master area
  154.     , ((modMask              , xK_comma ), sendMessage (IncMasterN 1))
  155.     , ((modMask              , xK_period), sendMessage (IncMasterN (-1)))
  156.  
  157.     -- resizing
  158.     , ((modMask,               xK_h     ), sendMessage Shrink)
  159.     , ((modMask,               xK_l     ), sendMessage Expand)
  160.     , ((modMask .|. shiftMask, xK_h     ), sendMessage MirrorShrink)
  161.     , ((modMask .|. shiftMask, xK_l     ), sendMessage MirrorExpand)
  162.  
  163.     -- quit, or restart
  164.     , ((modMask .|. shiftMask, xK_q     ), io (exitWith ExitSuccess))
  165.     , ((modMask              , xK_q     ), spawn "xmonad --recompile; xmonad --restart")
  166.     ]
  167.     ++
  168.     -- mod-[1..9] %! Switch to workspace N
  169.     -- mod-shift-[1..9] %! Move client to workspace N
  170.     [((m .|. modMask, k), windows $ f i)
  171.         | (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9]
  172.         , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]]
  173.     ++
  174.     -- mod-[w,e] %! switch to twinview screen 1/2
  175.     -- mod-shift-[w,e] %! move window to screen 1/2
  176.     [((m .|. modMask, key), screenWorkspace sc >>= flip whenJust (windows . f))
  177.         | (key, sc) <- zip [xK_w, xK_e] [0..]
  178.         , (f, m) <- [(W.view, 0), (W.shift, shiftMask)]]
  179.  
  180. -------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement