Advertisement
Guest User

Untitled

a guest
Jul 28th, 2010
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import XMonad
  2.  
  3. import XMonad.Hooks.ManageHelpers
  4. import XMonad.Hooks.DynamicLog
  5. import XMonad.Hooks.ManageDocks
  6. import XMonad.Hooks.SetWMName
  7. import XMonad.Hooks.InsertPosition
  8.  
  9. import XMonad.Actions.CycleWS
  10. import XMonad.Actions.DwmPromote
  11.  
  12. import XMonad.Layout.NoBorders
  13. import XMonad.Layout.IM
  14. import XMonad.Layout.PerWorkspace
  15. import XMonad.Layout.Reflect
  16. import XMonad.Layout.ResizableTile
  17. import XMonad.Layout.MultiToggle
  18. import XMonad.Layout.MultiToggle.Instances
  19.  
  20. import XMonad.Prompt
  21. import XMonad.Prompt.Shell
  22. import XMonad.Prompt.Workspace
  23. import XMonad.Prompt.AppendFile
  24.  
  25. import XMonad.Util.NamedScratchpad
  26. import XMonad.Util.Run
  27.  
  28. import qualified XMonad.StackSet as W
  29. import qualified Data.Map        as M
  30.  
  31. import System.Exit
  32.  
  33. main :: IO ()
  34. main = myConfig >>= xmonad
  35.  
  36. myConfig = do
  37.   workspaceBar <- spawnPipe "xmobar -x 0 ~/.xmobarrc"
  38.   return defaultConfig {
  39.      terminal           = "urxvtc",
  40.      startupHook        = setWMName "LG3D",
  41.      manageHook         = myManageHook,
  42.      borderWidth        = 1,
  43.      normalBorderColor  = black4,
  44.      focusedBorderColor = orange,
  45.      layoutHook         = myLayouts,
  46.      workspaces         = myWorkspaces,
  47.      keys               = myKeys,
  48.      logHook            = myLogHook workspaceBar
  49.   }
  50.  
  51. -------------------------
  52. -- LOGGING/STATUS BARS --
  53. -------------------------
  54.  
  55. myLogHook bar = dynamicLogWithPP $ defaultPP {
  56.         ppCurrent           =   xmobarColor orange "" . pad
  57.       , ppVisible           =   xmobarColor orange grey1 . pad
  58.       , ppHidden            =   xmobarColor white  "" . pad . removeNSP
  59.       , ppHiddenNoWindows   =   xmobarColor grey2  "" . pad . removeNSP
  60.       , ppSep               =   "| "
  61.       , ppWsSep             =   ""
  62.       , ppLayout            =   (++ " ") . xmobarColor orange "" . layoutNames
  63.       , ppTitle             =   xmobarColor white  ""
  64.       , ppOutput            =   hPutStrLn bar
  65.       }
  66.  
  67.  where
  68.  
  69.     removeNSP x
  70.      | x == "NSP" = []
  71.      | otherwise  = x
  72.  
  73.     layoutNames x
  74.      | x == "ResizableTall"        = "|"
  75.      | x == "Mirror ResizableTall" = "-"
  76.      | x == "Full"                 = "[]"
  77.      | x == "IM ReflectX IM Full"  = "|=|"
  78.      | otherwise                   = x
  79.  
  80. ------------------
  81. -- WINDOW RULES --
  82. ------------------
  83.  
  84. myManageHook = namedScratchpadManageHook genScratchPads <+> (composeOne . concat $
  85.    [ [ className =? x <&&> resource =? y -?> doFloat       | (x,y) <- specFloats  ]
  86.    , [ className =? x                    -?> doFloat       |  x    <- genFloats   ]
  87.    , [ className =? x                    -?> doCenterFloat |  x    <- cenFloats   ]
  88.    , [ isFullscreen                      -?> doFullFloat                          ]
  89.    , [ return True                       -?> insertPosition Below Newer           ]
  90.    ] ) <+> manageDocks <+> (composeOne . concat $
  91.    [ [ className =? x                    -?> doShift y     | (x,y) <- autoShifts ]])
  92.  
  93.   where
  94.  
  95.       specFloats  = [ ("Namoroka", "Extension")
  96.                     , ("Namoroka",  "Download")
  97.                     , ("Namoroka",   "Mozilla")
  98.                     , ("Namoroka",    "Dialog")
  99.                     , ("Namoroka",   "Browser")
  100.                     ]
  101.  
  102.       genFloats   = [ "Qsynth"
  103.                     , "MPlayer"
  104.                     ]
  105.  
  106.       cenFloats   = [
  107.                     ]
  108.  
  109.       autoShifts  = [ ("Gimp",      "gimp")
  110.                     , ("Qsynth",    "misc")
  111.                     , ("Qjackctl",  "misc")
  112.                     , ("Hydrogen",  "aud1")
  113.                     , ("Tuxguitar", "aud2")
  114.                     ]
  115.  
  116. -----------------
  117. -- SCRATCHPADS --
  118. -----------------
  119.  
  120. myScratchPads= [ ("terminal", "", 0.5, 0.33)
  121.                , ("htop", "htop", 0.8, 0.8)
  122.                , ("notes", "tail -F ~/bin/notes -s 60 -n 20", 0.2, 0.6)
  123.                ]
  124.  
  125. genScratchPads = map createPad myScratchPads
  126.   where
  127.     createPad (name,spawn,w,h)
  128.       | name == "terminal" = NS name
  129.                              (myTerm name)
  130.                              (resource =? name)
  131.                              (customFloating $ W.RationalRect ((1 - w)/2) ((1 - h)/2) w h)
  132.       | otherwise          = NS name
  133.                              ((myTerm name) ++ " -e " ++ spawn)
  134.                              (resource =? name)
  135.                              (customFloating $ W.RationalRect ((1 - w)/2) ((1 - h)/2) w h)
  136.  
  137. myScratchPadNames = map getName myScratchPads
  138.     where getName (x,_,_,_) = x
  139.  
  140. ------------
  141. -- PROMPT --
  142. ------------
  143.  
  144. myXPConfig :: XPConfig
  145. myXPConfig = defaultXPConfig
  146.           { font        = myFont
  147.           , bgColor     = black2
  148.           , fgColor     = white
  149.           , bgHLight    = black3
  150.           , fgHLight    = orange
  151.           , borderColor = black
  152.           , position    = Top
  153.           , height      = 17
  154.           }
  155.  
  156. -------------
  157. -- LAYOUTS --
  158. -------------
  159.  
  160. myLayouts = smartBorders
  161.             $ avoidStruts
  162.             $ onWorkspace "gimp" gimp
  163.             $ mkToggle (single NBFULL)
  164.             $ tiled ||| Mirror tiled
  165.   where
  166.      tiled   = ResizableTall nmaster delta ratio []
  167.      nmaster = 1
  168.      delta   = 1/20
  169.      ratio   = goldenRatio
  170.      gimp    = withIM (0.11) (Role "gimp-toolbox")
  171.                $ reflectHoriz
  172.                $ withIM (0.15) (Role "gimp-dock") Full
  173.  
  174. ------------------
  175. -- KEY BINDINGS --
  176. ------------------
  177.  
  178. myKeys ::  XConfig t -> M.Map (KeyMask, KeySym) (X ())
  179. myKeys conf@(XConfig {XMonad.modMask = modm}) = M.fromList $
  180.  
  181.     [ ((modm, xK_Return), spawn $ XMonad.terminal conf)
  182.     , ((modm,               xK_Escape ), kill)
  183.     , ((modm,               xK_grave  ), sendMessage NextLayout)
  184.     , ((modm,               xK_space  ), dwmpromote)
  185.     , ((modm,               xK_j      ), windows W.focusDown)
  186.     , ((modm,               xK_k      ), windows W.focusUp)
  187.     , ((modm .|. shiftMask, xK_j      ), windows W.swapDown)
  188.     , ((modm .|. shiftMask, xK_k      ), windows W.swapUp)
  189.     , ((modm,               xK_Left   ), prevWS)
  190.     , ((modm,               xK_Right  ), nextWS)
  191.     , ((modm,               xK_Tab    ), nextScreen)
  192.     , ((modm .|. shiftMask, xK_Tab    ), toggleWS)
  193.     , ((modm,               xK_s      ), sendMessage Shrink)
  194.     , ((modm,               xK_x      ), sendMessage Expand)
  195.     , ((modm,               xK_z      ), sendMessage MirrorShrink)
  196.     , ((modm,               xK_a      ), sendMessage MirrorExpand)
  197.     , ((modm,               xK_f      ), sendMessage $ Toggle NBFULL)
  198.     , ((modm,               xK_t      ), withFocused $ windows . W.sink)
  199.     , ((modm,               xK_comma  ), sendMessage (IncMasterN 1))
  200.     , ((modm,               xK_period ), sendMessage (IncMasterN (-1)))
  201.     , ((modm .|. shiftMask, xK_q      ), io (exitWith ExitSuccess))
  202.     , ((modm,               xK_q      ), spawn "killall xmobar; xmonad --recompile; xmonad --restart")
  203.     , ((modm,               xK_p      ), shellPrompt myXPConfig)
  204.     , ((modm,               xK_n      ), appendFilePrompt myXPConfig "/home/zak/bin/notes")
  205.     , ((modm,               xK_m      ), workspacePrompt myXPConfig $ windows . W.view)
  206.     , ((modm,               xK_o      ), spawn "~/bin/scripts/startut")
  207.     , ((modm,               xK_u      ), spawn powerTab)
  208.     , ((0,                  0x1008FF11), spawn "amixer -q set Master 5-")
  209.     , ((0,                  0x1008FF12), spawn "amixer -q set Master 0")
  210.     , ((0,                  0x1008FF13), spawn "amixer -q set Master 5+")
  211.     , ((0,                  0x1008FF14), spawn "ncmpcpp toggle")
  212.     , ((0,                  0x1008FF15), spawn "ncmpcpp stop")
  213.     , ((0,                  0x1008FF16), spawn "ncmpcpp prev")
  214.     , ((0,                  0x1008FF17), spawn "ncmpcpp next")
  215.     ]
  216.  
  217.     ++
  218.  
  219.     [ ((0, x), namedScratchpadAction genScratchPads y) | (x,y) <- zip [xK_F12, xK_F11..xK_F1] myScratchPadNames ]
  220.  
  221.     ++
  222.  
  223.     [((modm, k), windows $ W.greedyView i) | (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9]]
  224.  
  225.     ++
  226.  
  227.     [((modm .|. shiftMask, k), (windows $ W.shift i) >> (windows $ W.greedyView i) >> (windows $ W.swapDown))
  228.         | (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9]]
  229.  
  230. ------------
  231. -- COLORS --
  232. ------------
  233.  
  234. orange = "#ebac54"
  235. white  = "#ffffff"
  236. black  = "#000000"
  237. black1 = "#1f1f1f"
  238. black2 = "#1c1c1c"
  239. black3 = "#2c2c2c"
  240. black4 = "#3f3f3f"
  241. grey1  = "#4f4f4f"
  242. grey2  = "#7f7f7f"
  243.  
  244. --------------------------------
  245. -- SOME UGLY/LONG DEFINITIONS --
  246. --------------------------------
  247.  
  248. myWorkspaces   = ["www","dev","mus","chat","net","gimp","ex1","ex2","ex3"]
  249. myFont         = "-*-proggycleanszcp-medium-r-normal-*-13-80-96-96-c-70-iso8859-1"
  250. myTerm x       = "urxvtc +sb -fn '" ++ myFont ++ "' -fb '" ++ myFont ++ "' -fi '" ++ myFont ++ "' -name " ++ x
  251. powerTab       = "wine .wine/drive_c/'Program Files'/'Power Tab Software'/'Power Tab Editor 1.7'/PTEditor.exe"
  252. goldenRatio    = toRational $ 2/(1 + sqrt 5 :: Double)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement