Advertisement
Guest User

Sean Neilan

a guest
Feb 16th, 2010
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Haskell 11.21 KB | None | 0 0
  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. {-# OPTIONS_GHC -fglasgow-exts #-} -- required for XMonad.Layout.MultiToggle
  11.  
  12. import XMonad
  13. import XMonad.Actions.CycleWS
  14. import XMonad.Actions.DwmPromote
  15. import XMonad.Actions.FindEmptyWorkspace
  16. import qualified XMonad.Actions.FlexibleResize as Flex
  17. import XMonad.Actions.RotSlaves
  18. import XMonad.Actions.Search
  19. import XMonad.Actions.WindowGo
  20. import XMonad.Hooks.DynamicLog as Log
  21. import XMonad.Hooks.ManageDocks
  22. import XMonad.Hooks.EwmhDesktops
  23. import XMonad.Util.Run (spawnPipe)
  24. import XMonad.Util.EZConfig
  25. import XMonad.Prompt
  26. import XMonad.Prompt.RunOrRaise
  27. import XMonad.Prompt.Shell
  28. import XMonad.Prompt.Ssh
  29. import XMonad.Prompt.Workspace
  30. import XMonad.Util.Dzen as Dzen
  31. import XMonad.Util.Run
  32. import XMonad.Util.Loggers
  33. import XMonad.Layout.Accordion
  34. import XMonad.Layout.Combo
  35. import XMonad.Layout.DwmStyle
  36. import XMonad.Layout.IM
  37. import XMonad.Layout.Maximize
  38. import XMonad.Layout.MultiToggle
  39. import XMonad.Layout.NoBorders
  40. import XMonad.Layout.PerWorkspace
  41. import XMonad.Layout.Reflect
  42. import XMonad.Layout.ResizableTile
  43. import XMonad.Layout.TwoPane
  44. import XMonad.Layout.WindowNavigation
  45.  
  46. import Codec.Binary.UTF8.String
  47. import Control.Monad
  48. import Data.Ratio ((%))
  49. import System.Exit
  50. import System.IO (hPutStrLn)
  51.  
  52. import qualified XMonad.StackSet as W
  53. import qualified Data.Map        as M
  54.  
  55. myTerminal = "xterm -bg black -fg '#CFDBFF' -fn '-*-terminus-medium-*-*-*-20-*-*-*-*-*-iso10646-1' +sb -bdc"
  56.  
  57. myBorderWidth   = 1
  58. myModMask       = mod1Mask
  59. myNumlockMask   = mod2Mask
  60.  
  61. myWorkspaces    = ["~"] ++ map show [1..2] ++ ["web","IM","mail","6","7","8","mpc","0","rdesktop"]
  62. myDefaultGaps   = [(0,0,0,0)]
  63.  
  64. myNormalBorderColor  = "#444488"
  65. myFocusedBorderColor = "#ee9999"
  66.  
  67. myBgColor= "#001070"
  68. myFgColor = "#bbbbdd"
  69. myBgHLight= "#4444aa"
  70. myFgHLight= "#ddddff"
  71.  
  72. myXPConfig :: XPConfig
  73. myXPConfig = defaultXPConfig
  74.               { font        = "xft:Terminus:pixelsize=16"
  75.           , bgColor     = myBgColor
  76.           , fgColor     = myFgColor
  77.           , bgHLight    = myBgHLight
  78.           , fgHLight    = myFgHLight
  79.               , borderColor = myNormalBorderColor
  80.               }
  81.  
  82. -- Mutimedia keys bindings
  83. multKeys conf@(XConfig {XMonad.modMask = modMask}) = M.fromList $ [
  84.       ((0, 0x1008ff14), spawn "mpc --no-status toggle")
  85.     , ((0, 0x1008ff15), spawn "mpc --no-status stop")
  86.     , ((0, 0x1008ff16), spawn "mpc --no-status prev")
  87.     , ((0, 0x1008ff17), spawn "mpc --no-status next")
  88.     , ((0, 0x1008ff11), spawn "mpcvolume -")
  89.     , ((0, 0x1008ff13), spawn "mpcvolume +")
  90.  
  91.     , ((0, 0x1008ff18), runOrRaise "firefox" (className =? "Firefox-bin"))
  92.     , ((0, 0x1008ff19), runOrRaise "claws-mail" (className =? "Claws-mail"))
  93.     , ((0, 0x1008ff30), runOrRaise "kvirc" (className =? "Kvirc"))
  94.  
  95.     , ((0, 0x1008ff10), spawn "/usr/bin/xscreensaver-command -lock")
  96.     , ((0, xK_Print), unsafeSpawn "import -w root png:$HOME/screenshot--`date +%F--%T`.png")
  97.     ]
  98.  
  99. myKeys = \conf -> mkKeymap conf $ [
  100.  
  101.       ("M-S-<Return>", spawn $ XMonad.terminal conf)    -- terminal
  102.  
  103.     , ("M-S-c", kill)
  104.     , ("M-r", refresh)
  105.     , ("M-b", sendMessage ToggleStruts)
  106.  
  107.     , ("M-S-C-<Pause>", io (exitWith ExitSuccess))
  108.     , ("M-q", restart "xmonad" True)
  109.  
  110. -- Propmpts here
  111.     , ("M-p p", runOrRaisePrompt myXPConfig)
  112.     , ("M-p M-p", runOrRaisePrompt myXPConfig)
  113.     , ("M-p t", prompt (myTerminal ++ " -e") myXPConfig)
  114.     , ("M-p M-t", prompt (myTerminal ++ " -e") myXPConfig)
  115.     , ("M-p s", sshPrompt myXPConfig)
  116.     , ("M-p M-s", sshPrompt myXPConfig)
  117.     , ("M-p w", workspacePrompt myXPConfig (windows . W.view))
  118.     , ("M-p S-w", workspacePrompt myXPConfig (windows . W.shift))
  119.     , ("M-p M-w", workspacePrompt myXPConfig (windows . W.view))
  120.     , ("M-p M-S-w", workspacePrompt myXPConfig (windows . W.shift))
  121.     , ("M-S-b", selectSearch bugzilla)
  122.     , ("M-p M-r", prompt ("rdesktop -k en-us") myXPConfig)
  123.  
  124. -- Workspaces
  125.     , ("M-z", viewEmptyWorkspace)
  126.     , ("M-<L>", prevWS)
  127.     , ("M-<R>", nextWS)
  128.  
  129.     , ("M-<Space>", sendMessage NextLayout)
  130.     , ("M-S-<Space>", setLayout $ XMonad.layoutHook conf)
  131.  
  132. --- Window management
  133.     , ("M-h", sendMessage $ Go L)
  134.     , ("M-S-h", sendMessage $ Swap L)
  135.     , ("M-j", sendMessage $ Go D)
  136.     , ("M-S-j", sendMessage $ Swap D)
  137.     , ("M-k", sendMessage $ Go U)
  138.     , ("M-S-k", sendMessage $ Swap U)
  139.     , ("M-l", sendMessage $ Go R)
  140.     , ("M-S-l", sendMessage $ Swap R)
  141.  
  142.     , ("M-<Tab>", windows W.focusDown)
  143.     , ("M-S-<Tab>", windows W.focusUp)
  144.  
  145.     , ("M-<Return>", windows W.focusMaster)
  146.     , ("M-m", dwmpromote)
  147.  
  148.     , ("M-y", rotSlavesDown)
  149.     , ("M-S-y", rotAllDown)
  150.     , ("M-o", rotSlavesUp)
  151.     , ("M-S-o", rotAllUp)
  152.  
  153.     , ("M-S-u", sendMessage Shrink)
  154.     , ("M-S-i", sendMessage Expand)
  155.     , ("M-u", sendMessage MirrorExpand)
  156.     , ("M-i", sendMessage MirrorShrink)
  157.  
  158.     , ("M-v", withFocused $ sendMessage . maximizeRestore )
  159.     , ("M-s", sendMessage $ Toggle ACCORDION)
  160.     , ("M-S-s", sendMessage $ Toggle FULL)
  161.     , ("M-t", withFocused $ windows . W.sink)   -- unfloat
  162.  
  163.     -- Increment the number of windows in the master area
  164.     , ("M-,", sendMessage (IncMasterN 1))
  165.     , ("M-.", sendMessage (IncMasterN (-1)))
  166.     ]
  167.  
  168.     ++
  169.  
  170.     [ (m ++ i, windows $ f j)
  171.                     | (i, j) <- zip (["`"] ++ map show [1..9] ++ ["0","C-r"] ) (XMonad.workspaces conf)
  172.                     , (m, f) <- [("M-", W.view), ("M-S-", W.shift)]
  173. --                    , (m, f) <- [("M-", W.greedyView), ("M-S-", W.shift)]
  174.     ]
  175.  
  176. --- xinerama not used
  177.     -- ++
  178.  
  179.     -- mod-{w,e,r}, Switch to physical/Xinerama screens 1, 2, or 3
  180.     -- mod-shift-{w,e,r}, Move client to screen 1, 2, or 3
  181.    
  182.     --[ ((m .|. modMask, key), screenWorkspace sc >>= flip whenJust (windows . f))
  183.         -- | (key, sc) <- zip [xK_w, xK_e, xK_r] [0..]
  184.         -- , (f, m) <- [(W.view, 0), (W.shift, shiftMask)]]
  185.     ++
  186.     [ (m ++ key, screenWorkspace sc >>= flip whenJust (windows . f))
  187.         | (key, sc) <- zip ["w", "e"] [0..]
  188.     , (m, f) <- [("M-", W.view), ("M-S-", W.shift)]
  189.     ]
  190. bugzilla = searchEngine "bugzilla" "https://bugzilla.altlinux.org/show_bug.cgi?id="
  191.  
  192. ------------------------------------------------------------------------
  193. -- Mouse bindings: default actions bound to mouse events
  194. --
  195. myMouseBindings (XConfig {XMonad.modMask = modMask}) = M.fromList $
  196.  
  197.     -- mod-button1, Set the window to floating mode and move by dragging
  198.     [ ((modMask, button1), (\w -> focus w >> mouseMoveWindow w))
  199.  
  200.     -- mod-button2, Raise the window to the top of the stack
  201.     , ((modMask, button2), (\w -> focus w >> windows W.swapMaster))
  202.  
  203.     -- mod-button3, Set the window to floating mode and resize by dragging
  204.     , ((modMask, button3), (\w -> focus w >> Flex.mouseResizeWindow w))
  205.  
  206.     -- you may also bind events to the mouse scroll wheel (button4 and button5)
  207. --    , ((modMask, button4), prevWS)
  208. --    , ((modMask, button5), nextWS)
  209.     ]
  210.  
  211. data ACCORDION = ACCORDION deriving (Read, Show, Eq, Typeable)
  212. instance Transformer ACCORDION Window where
  213.       transform _ x k = k Accordion
  214.  
  215. data FULL = FULL deriving (Read, Show, Eq, Typeable)
  216. instance Transformer FULL Window where
  217.       transform _ x k = k Full
  218.  
  219. data NOBORDERS = NOBORDERS deriving (Read, Show, Eq, Typeable)
  220. instance Transformer NOBORDERS Window where
  221.       transform _ x k = k (noBorders x)
  222.  
  223. myLayout = ewmhDesktopsLayout . dwmStyle shrinkText myTheme . windowNavigation . avoidStruts . maximize . mkToggle (single ACCORDION) . mkToggle (NOBORDERS ?? FULL ?? EOT) $ onWorkspace "IM" tiledIM (Mirror tiled) ||| onWorkspace "IM" (Mirror tiled) tiledIM
  224.   where
  225.      tiled   = ResizableTall 1 0.03 0.6180 []
  226.      tiledIM   = ResizableTall 1 0.03 0.85 []
  227.  
  228. myTheme = defaultTheme {
  229.             activeColor = myBgHLight
  230.           , activeTextColor = myFgHLight
  231.       , inactiveColor = myBgColor
  232.       , inactiveTextColor = myFgColor
  233.           }
  234.  
  235. myManageHook = composeAll
  236.      [
  237.        moveToC "Firefox-bin" "web"
  238.      , floatT "Save a Bookmark"
  239.      , moveToC "Claws-mail" "mail"
  240.      , moveToC "rdesktop" "rdesktop"
  241.      , moveToC "Kvirc" "IM"
  242.      , moveToC "mainwnd" "IM"
  243.      , floatC "Xmessage"
  244.      , floatC "container"
  245.      , floatC "history"
  246.      , floatT $ decode [0xd0, 0x9f, 0xd0, 0xbe, 0xd0, 0xbc, 0xd0, 0xb5, 0xd1, 0x82, 0xd0, 0xb8, 0xd1, 0x82, 0xd1, 0x8c, 0x20, 0xd0, 0xba, 0xd0, 0xb0, 0xd0, 0xba, 0x20, 0xd0, 0xbf, 0xd1, 0x80, 0xd0, 0xbe, 0xd1, 0x87, 0xd0, 0xb8, 0xd1, 0x82, 0xd0, 0xb0, 0xd0, 0xbd, 0xd0, 0xbd, 0xd0, 0xbe, 0xd0, 0xb5]
  247.      ] <+> manageDocks
  248.      where
  249.        moveToC c w = className =? c --> doF (W.shift w)
  250.        moveToT t w = title =? t --> doF (W.shift w)
  251.        floatC c = className =? c --> doFloat
  252.        floatT t = title =? t --> doFloat
  253.  
  254. -- Whether focus follows the mouse pointer.
  255. myFocusFollowsMouse :: Bool
  256. myFocusFollowsMouse = True
  257.  
  258.  
  259. ------------------------------------------------------------------------
  260. -- Startup hook
  261.  
  262. -- Perform an arbitrary action each time xmonad starts or is restarted
  263. -- with mod-q.  Used by, e.g., XMonad.Layout.PerWorkspace to initialize
  264. -- per-workspace layout choices.
  265. --
  266. -- By default, do nothing.
  267. myStartupHook = do
  268.   spawn "xsetroot -cursor_name left_ptr -solid '#001040'"
  269. --return ()
  270.  
  271.  
  272. --myLogHook = return ()
  273.  
  274.  
  275. ------------------------------------------------------------------------
  276. -- Now run xmonad with all the defaults we set up.
  277.  
  278. -- Run xmonad with the settings you specify. No need to modify this.
  279. --
  280. main = do
  281.   dzen2 <- spawnPipe ( "killall rundzen; rundzen --" ++ (join $ map (wrap "-" "-") myWorkspaces ))
  282.  
  283.   Log.dzen $ \ defaultConfig -> xmonad $
  284.  
  285. -- A structure containing your configuration settings, overriding
  286. -- fields in the default config. Any you don't override, will
  287. -- use the defaults defined in xmonad/XMonad/Config.hs
  288. --
  289.     defaultConfig {
  290.       -- simple stuff
  291.         terminal           = myTerminal,
  292.         focusFollowsMouse  = myFocusFollowsMouse,
  293.         borderWidth        = myBorderWidth,
  294.         modMask            = myModMask,
  295.         numlockMask        = myNumlockMask,
  296.         workspaces         = myWorkspaces,
  297.         normalBorderColor  = myNormalBorderColor,
  298.         focusedBorderColor = myFocusedBorderColor,
  299. --        defaultGaps        = myDefaultGaps,
  300.  
  301.       -- key bindings
  302.         keys               = \c -> myKeys c `M.union` multKeys c,
  303.         mouseBindings      = myMouseBindings,
  304.  
  305.       -- hooks, layouts
  306.         layoutHook         = myLayout,
  307.         manageHook         = myManageHook,
  308. --        logHook            = do
  309. --                         ewmhDesktopsLogHook
  310. --                 dynamicLogWithPP dzenPP {
  311. --                            ppCurrent = dzenColor myFgHLight myBgHLight . wrap "-" "-"
  312. --                            , ppTitle = (>> "")
  313. --                            , ppLayout = (>> "")
  314. --                            , ppHidden = dzenColor myFgColor myBgColor . wrap " " " "
  315. --                            , ppSep = " | "
  316. --                            , ppExtras = [ logCmd "gcpubar -c 1" ]
  317. --                                                    , ppOutput = hPutStrLn dzen2 },
  318.         startupHook        = myStartupHook
  319.     }
  320.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement