MPogoda

MPogoda's xmonad

Jan 8th, 2013
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import Data.List            (isPrefixOf)
  2. import Control.Applicative  ((<$>))
  3. import System.Exit          (exitWith, ExitCode(..))
  4.  
  5. import XMonad                       hiding (Tall(..))
  6. import XMonad.Hooks.DynamicLog      (statusBar, xmobarPP, xmobarColor, ppCurrent, wrap)
  7. import XMonad.Hooks.EwmhDesktops    (ewmh, fullscreenEventHook)
  8. import XMonad.Hooks.ManageDocks     (docksEventHook, ToggleStruts(..))
  9. import XMonad.Layout.NoBorders      (smartBorders)
  10. import XMonad.Layout.ResizableTile  (ResizableTall(..), MirrorResize(..))
  11. import XMonad.Layout.LayoutHints    (layoutHintsToCenter, hintsEventHook)
  12. import XMonad.Util.EZConfig         (mkKeymap)
  13.  
  14. import qualified XMonad.StackSet as W
  15. import qualified Data.Map        as M
  16.  
  17. main :: IO ()
  18. main = do
  19.   xmonad =<< statusBar "xmobar" myPP toggleStrutsKey defaults
  20.   where
  21.     defaults = ewmh defaultConfig
  22.       { terminal           = "urxvtc"
  23.       , borderWidth        = 5
  24.       , modMask            = mod4Mask
  25.       , workspaces         = words "a s d f z x c v"
  26.       , normalBorderColor  = darkGray
  27.       , focusedBorderColor = darkOrange
  28.       , layoutHook         = layoutHintsToCenter . smartBorders $
  29.                                 myLayout
  30.       , manageHook         = myManageHook
  31.       , handleEventHook    = myEventHook
  32.       , keys               = myKeys
  33.       }
  34.     -- Layouts -----------------------------------
  35.     myLayout = tiled ||| Mirror tiled ||| Full
  36.     tiled   = ResizableTall nmaster delta ratio []
  37.     nmaster = 1     -- number of windows in master pane
  38.     ratio   = toRational (2/(1+sqrt(5)::Double))
  39.     delta   = 3/100 -- step of increasing
  40.  
  41.     -- Manage windows
  42.     myManageHook = composeAll
  43.       (
  44.       [ myIgnores --> doIgnore -- Don't manage
  45.       , myFloats  --> doFloat  -- Make floating
  46.       ]
  47.       ++
  48.       -- shifting to workspace based on window class
  49.       [ className =? x --> doShift w | (x, w) <- clsShifts ]
  50.       ++
  51.       -- shifting to workspace based on window name
  52.       [ resource =? x --> doShift w  | (x, w) <- rcsShifts ]
  53.       )
  54.     myFloats = foldr1 (<||>)
  55.       [ ("Figure" `isPrefixOf`) <$> title
  56.       , className =? "feh"
  57.       , className =? "mplayer2"
  58.       ]
  59.     myIgnores = foldr1 (<||>)
  60.       [ resource  =? "panel"
  61.       , resource  =? "trayer"
  62.       , className =? "stalonetray"
  63.       ]
  64.     -- [ ( className, workspace) ]
  65.     clsShifts = [ ("Chromium-browser", "s")
  66.                 , ("Leechcraft", "a")
  67.                 , ("Djview", "z")
  68.                 ] :: [(String,  String)]
  69.     rcsShifts = [ ("ncmpc", "d")
  70.                 ] :: [(String, String)]
  71.  
  72.     -- eventHook
  73.     myEventHook = docksEventHook <+> hintsEventHook <+> fullscreenEventHook
  74.  
  75.     -- xmobar staff
  76.     myPP = xmobarPP { ppCurrent = xmobarColor orange "" . wrap "<" ">" }
  77.     toggleStrutsKey XConfig { XMonad.modMask = modMask } = (modMask, xK_b)
  78.  
  79.     -- Keys
  80.     myKeys = \conf -> mkKeymap conf $
  81.        [ ("M-<Return>",   spawn       $ term conf)
  82.        , ("M-C-<Esc>",    spawn       $ "xkill")
  83.        , ("M-r",          spawn       $ "dmenu_run")
  84.        , ("M-<Space>",    sendMessage $ NextLayout)
  85.        , ("M-S-<Space",   setLayout   $ XMonad.layoutHook conf)
  86.        , ("M-n",          refresh)
  87.        , ("M-j",          windows     $ W.focusDown)
  88.        , ("M-k",          windows     $ W.focusUp)
  89.        , ("M-m",          windows     $ W.focusMaster)
  90.        , ("M-S-j",        windows     $ W.swapDown)
  91.        , ("M-S-k",        windows     $ W.swapUp)
  92.        , ("M-S-m",        windows     $ W.swapMaster)
  93.        , ("M-h",          sendMessage $ Shrink)
  94.        , ("M-l",          sendMessage $ Expand)
  95.        , ("M-t",          withFocused $ windows . W.sink)
  96.        , ("M-,",          sendMessage $ IncMasterN 1)
  97.        , ("M-.",          sendMessage $ IncMasterN (-1))
  98.        , ("M-u",          sendMessage $ MirrorShrink)
  99.        , ("M-i",          sendMessage $ MirrorExpand)
  100.        , ("M-b",          sendMessage $ ToggleStruts)
  101.        , ("M-S-q",        io          $ exitWith ExitSuccess)
  102.        , ("M-q",          restart "xmonad" True)
  103.        , (prefix "c",     kill)
  104.        , (prefix "b",     spawn       $ "chromium")
  105.        , (prefix "n",     spawn       $ ncmpcTerm conf)
  106.        , (prefix "e",     spawn       $ "gvim")
  107.        ]
  108.        ++
  109.        -- M-[asdfzxcv]   : switch to corresponding workspace
  110.        -- M-S-[asdfzxcv] : move window to " " " " " " "
  111.        [ ( m ++ i, windows $ f j)
  112.           | (i, j) <- zip (XMonad.workspaces conf) (XMonad.workspaces conf)
  113.           , (m, f) <- [("M-", W.view), ("M-S-", W.shift)]
  114.        ]
  115.     prefix s    = "M-<Tab> " ++ s
  116.     term c      = XMonad.terminal c
  117.     sTerm c     = term c ++ " -name urxvt-am -e "
  118.     ncmpcTerm c = term c ++ " -name ncmpc -e ncmpc"
  119.  
  120.     -- colors
  121.     orange     = "#ee9a00"
  122.     darkOrange = "#9e4a00"
  123.     darkGray   = "#3d3d3d"
Advertisement
Add Comment
Please, Sign In to add comment