Created
August 29, 2011 10:45
-
-
Save micrypt/1178166 to your computer and use it in GitHub Desktop.
XMonad config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| atom_WM_TAKE_FOCUS :: | |
| X Atom | |
| atom_WM_TAKE_FOCUS = | |
| getAtom "WM_TAKE_FOCUS" | |
| takeFocusX :: | |
| Window | |
| -> X () | |
| takeFocusX w = | |
| withWindowSet . const $ do | |
| dpy <- asks display | |
| wmtakef <- atom_WM_TAKE_FOCUS | |
| wmprot <- atom_WM_PROTOCOLS | |
| protocols <- io $ getWMProtocols dpy w | |
| when (wmtakef `elem` protocols) $ | |
| io . allocaXEvent $ \ev -> do | |
| setEventType ev clientMessage | |
| setClientMessageEvent ev w wmprot 32 wmtakef currentTime | |
| sendEvent dpy w False noEventMask ev | |
| takeTopFocus :: | |
| X () | |
| takeTopFocus = | |
| withWindowSet $ maybe (setFocusX =<< asks theRoot) takeFocusX . W.peek |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sudo apt-get install ghc6 cabal-install && cabal update && cabal install xmonad-contrib && cabal install xmobar && gconftool-2 -s /desktop/gnome/session/required_components/windowmanager xmonad --type string && echo "export PATH=$HOME/.cabal/bin:$PATH" >> ~/.profile | |
| gconftool-2 -s /desktop/gnome/session/required_components/windowmanager xmonad --type string | |
| #config.hs and then takeTopFocus >> setWMName "LG3D" in the logHook |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import XMonad | |
| import XMonad.Actions.UpdatePointer | |
| import XMonad.Actions.GridSelect | |
| import XMonad.Hooks.ManageDocks | |
| import XMonad.Hooks.DynamicLog hiding (dzen) | |
| import XMonad.Hooks.SetWMName | |
| import XMonad.Hooks.ManageHelpers | |
| import qualified XMonad.StackSet as W | |
| import System.Exit | |
| import Control.Monad | |
| import XMonad.Prompt | |
| import XMonad.Prompt.RunOrRaise | |
| import XMonad.Config.Gnome | |
| import XMonad.Prompt.Input | |
| import XMonad.Prompt.Theme | |
| import XMonad.Prompt.XMonad | |
| import XMonad.Prompt.Window | |
| import XMonad.Util.Paste | |
| import XMonad.Util.XSelection | |
| import XMonad.Layout.SimpleDecoration | |
| import XMonad.Layout.Tabbed | |
| import XMonad.Layout.NoFrillsDecoration | |
| import XMonad.Layout.Magnifier | |
| import XMonad.Config.DescriptiveKeys | |
| import XMonad.Layout.NoBorders | |
| main :: | |
| IO () | |
| main = | |
| xmonad =<< xmb | |
| ws1 :: | |
| String | |
| ws1 = | |
| "1:www" | |
| ws2 :: | |
| String | |
| ws2 = | |
| "2" | |
| ws3 :: | |
| String | |
| ws3 = | |
| "3" | |
| ws4 :: | |
| String | |
| ws4 = | |
| "4" | |
| ws5 :: | |
| String | |
| ws5 = | |
| "5" | |
| ws6 :: | |
| String | |
| ws6 = | |
| "6" | |
| ws7 :: | |
| String | |
| ws7 = | |
| "7" | |
| ws8 :: | |
| String | |
| ws8 = | |
| "8:mail" | |
| ws9 :: | |
| String | |
| ws9 = | |
| "9:music" | |
| ws :: [String] | |
| ws = | |
| [ws1, ws2, ws3, ws4, ws5, ws6, ws7, ws8, ws9] | |
| showws :: | |
| String | |
| -> Bool | |
| showws x = | |
| x `elem` [ws1, ws2, ws3, ws4, ws5, ws6, ws7, ws8, ws9] | |
| atom_WM_TAKE_FOCUS :: | |
| X Atom | |
| atom_WM_TAKE_FOCUS = | |
| getAtom "WM_TAKE_FOCUS" | |
| takeFocusX :: | |
| Window | |
| -> X () | |
| takeFocusX w = | |
| withWindowSet . const $ do | |
| dpy <- asks display | |
| wmtakef <- atom_WM_TAKE_FOCUS | |
| wmprot <- atom_WM_PROTOCOLS | |
| protocols <- io $ getWMProtocols dpy w | |
| when (wmtakef `elem` protocols) $ | |
| io . allocaXEvent $ \ev -> do | |
| setEventType ev clientMessage | |
| setClientMessageEvent ev w wmprot 32 wmtakef currentTime | |
| sendEvent dpy w False noEventMask ev | |
| takeTopFocus :: | |
| X () | |
| takeTopFocus = | |
| withWindowSet $ maybe (setFocusX =<< asks theRoot) takeFocusX . W.peek | |
| unfloatClasses :: | |
| ManageHook | |
| unfloatClasses = | |
| let unfloat = ask >>= doF . W.sink | |
| in composeAll $ | |
| (\c -> className =? c --> unfloat) | |
| `fmap` | |
| [ | |
| "rdesktop" | |
| , "Tsclient" | |
| , "Googleearth-bin" | |
| , "Gnome-screenshot" | |
| , "Kdenlive" | |
| , "java-lang-Thread" | |
| ] | |
| unfloatResources :: | |
| ManageHook | |
| unfloatResources = | |
| let unfloat = ask >>= doF . W.sink | |
| in composeAll $ | |
| (\c -> resource =? c --> unfloat) | |
| `fmap` | |
| [ | |
| "x64.exe" | |
| ] | |
| floatClasses :: | |
| ManageHook | |
| floatClasses = | |
| composeAll $ | |
| (\c -> className =? c --> doFloat) | |
| `fmap` | |
| [ | |
| ] | |
| shiftClasses :: | |
| ManageHook | |
| shiftClasses = | |
| composeAll $ | |
| (\(c, w) -> className =? c --> doShift w) | |
| `fmap` | |
| [ | |
| ("Thunderbird", ws8) | |
| , ("Xchat" , ws8) | |
| , ("Skype" , ws8) | |
| , ("Gwibber" , ws8) | |
| , ("Music" , ws9) | |
| , ("Rhythmbox" , ws9) | |
| , ("Banshee" , ws9) | |
| , ("banshee" , ws9) | |
| , ("banshee-1" , ws9) | |
| ] | |
| focusNowClasses :: | |
| ManageHook | |
| focusNowClasses = | |
| let viewShift = doF . liftM2 (.) W.greedyView W.shift | |
| in composeAll $ | |
| (\(c, w) -> className =? c --> viewShift w) | |
| `fmap` | |
| [ | |
| ("Firefox", ws1) | |
| , ("chromium-browser", ws1) | |
| ] | |
| gsConfig :: | |
| HasColorizer a => | |
| GSConfig a | |
| gsConfig = | |
| defaultGSConfig { | |
| gs_cellheight = 120 | |
| , gs_cellwidth = 200 | |
| } | |
| xpConfig :: | |
| XPConfig | |
| xpConfig = | |
| defaultXPConfig { | |
| borderColor = "#00ff00" | |
| , font = "-misc-fixed-*-*-*-*-14-*-*-*-*-*-*-*" | |
| } | |
| startTheme :: | |
| Theme | |
| startTheme = | |
| Theme { | |
| activeColor = "#2b4f98" | |
| , inactiveColor = "#cccccc" | |
| , urgentColor = "#FFFF00" | |
| , inactiveBorderColor = "#2b4f98" | |
| , activeBorderColor = "#cccccc" | |
| , urgentBorderColor = "##00FF00" | |
| , activeTextColor = "white" | |
| , inactiveTextColor = "black" | |
| , urgentTextColor = "#FF0000" | |
| , fontName = "-misc-fixed-*-*-*-*-14-*-*-*-*-*-*-*" | |
| , decoWidth = 200 | |
| , decoHeight = 16 | |
| } | |
| xConfig = | |
| helpPrompt (\l -> HelpPromptConfig { | |
| descriptiveHelp = xKeys | |
| , xpConfigHelp = xpConfig | |
| , keyHelp = (mod4Mask, xK_F1) | |
| , searchTextHelp = defaultSearchTextPrompt | |
| , describeHelp = defaultDescribeKeys xKeys l | |
| }) . | |
| setDescriptiveKeys xKeys $ | |
| gnomeConfig { | |
| modMask = mod4Mask | |
| , borderWidth = 4 | |
| , workspaces = ws | |
| , focusedBorderColor = "#b04fff" | |
| , layoutHook = let tiled = Tall 1 (3/100) (1/2) | |
| nf = noFrillsDeco shrinkText startTheme | |
| a = nf tiled | |
| b = tabbedAlways shrinkText startTheme | |
| c = nf (Mirror tiled) | |
| layout = a | |
| ||| b | |
| ||| c | |
| in smartBorders layout -- for a layout (l) specific to a workspace (wsN): smartBorders $ onWorkspace wsN lay layout (XMonad.Layout.PerWorkspace) | |
| , terminal = "/usr/bin/gnome-terminal" | |
| , logHook = dynamicLogWithPP xmbPP >> updatePointer (Relative 0.5 0.5) >> takeTopFocus >> setWMName "LG3D" | |
| , manageHook = let windowAction a w = withDisplay $ \d -> io $ a d w | |
| windowActionHook a = ask >>= \w -> liftX (a w) >> idHook | |
| isDockWindow = isInProperty "_NET_WM_WINDOW_TYPE" "_NET_WM_WINDOW_TYPE_DOCK" | |
| isDesktopWindow = isInProperty "_NET_WM_WINDOW_TYPE" "_NET_WM_WINDOW_TYPE_DESKTOP" | |
| in composeAll [ | |
| manageHook gnomeConfig | |
| , isDesktopWindow --> windowActionHook (windowAction lowerWindow) | |
| , isDockWindow --> windowActionHook (windowAction raiseWindow) | |
| , unfloatClasses | |
| , floatClasses | |
| , shiftClasses | |
| , focusNowClasses | |
| , unfloatResources | |
| , isFullscreen --> doFullFloat | |
| ] | |
| } | |
| xmb = | |
| let toggleStrutsKey XConfig{modMask = modm} = (modm, xK_b) | |
| in statusBar "xmobar" xmbPP toggleStrutsKey xConfig | |
| xmbPP :: | |
| PP | |
| xmbPP = | |
| xmobarPP { | |
| ppHidden = xmobarColor "#666666" "#222222" . pad | |
| , ppVisible = xmobarColor "#ffffff" "#222222" . pad | |
| , ppCurrent = xmobarColor "#ffffff" "#b04fff" . pad | |
| , ppHiddenNoWindows = const [] | |
| , ppUrgent = xmobarColor "red" "yellow" | |
| , ppLayout = xmobarColor "#ffffff" "#222222" | |
| , ppSep = " | " | |
| , ppWsSep = [] | |
| } | |
| terminal' :: | |
| String | |
| terminal' = | |
| terminal xConfig | |
| xKeys :: | |
| DescriptiveKeys | |
| xKeys = wKeys $ \c -> | |
| let m = modMask c | |
| sh = m .|. shiftMask | |
| ct = m .|. controlMask | |
| in | |
| [ | |
| (ct, xK_x , runOrRaisePrompt xpConfig, "run or raise prompt", ["run", "raise", "prompt"]) | |
| , (sh, xK_x , xmonadPrompt xpConfig, "prompt for xmonad command", ["prompt", "xmonad"]) | |
| , (ct, xK_t , themePrompt xpConfig, "prompt to change the theme of the current workspace", ["prompt", "theme"]) | |
| , (sh, xK_g , windowPromptGoto xpConfig, "go to window", ["window", "prompt", "goto"]) | |
| , (sh, xK_b , windowPromptBring xpConfig, "bring window", ["window", "prompt", "bring"]) | |
| , (sh, xK_g , goToSelected gsConfig, "launch GridSelect", ["grid", "select"]) | |
| , (m , xK_g , inputPrompt xpConfig "Google" ?+ \s -> spawn ("browse \"http://www.google.com/search?q=" ++ s ++ "\""), "Google for a phrase", ["google", "browser", "prompt"]) | |
| , (ct, xK_g , inputPrompt xpConfig "Define" ?+ \s -> spawn ("browse \"http://www.google.com/search?q=define%3A" ++ s ++ "\""), "Define a phrase", ["google", "define", "browser", "prompt"]) | |
| , (m , xK_e , spawnSelected gsConfig ["firefox", "idea", "gedit", "ktorrent"], "launch GridSelect with defined applications", ["grid", "select"]) | |
| , (ct, xK_p , pasteSelection, "paste the current selection", ["paste", "selection"]) | |
| , (sh, xK_f , transformPromptSelection ("http://www.google.com/search?q=" ++) "browse", "google the current selection", ["prompt", "selection", "google"]) | |
| , (ct, xK_d , transformPromptSelection ("http://www.google.com/search?q=define%3A" ++) "browse", "define the current selection with google", ["prompt", "selection", "google", "define"]) | |
| , (m , xK_f , spawn "browse", "launch a browser", ["launch", "browser"]) | |
| , (m , xK_c , spawn "browse \"https://www.google.com/calendar/render?tab=mc\"", "launch a browser with google calendar", ["launch", "browser", "calendar"]) | |
| , (m , xK_v , spawn "browse \"http://www.ebroadcast.com.au/tv/static/BrisbaneNight.html\"", "launch a browser with the brisbane television guide", ["launch", "browser", "television", "tv"]) | |
| , (sh, xK_w , spawn "browse \"http://www.bom.gov.au/qld/forecasts/brisbane.shtml\"", "launch a browser with BOM Brisbane forecast", ["launch", "browser", "weather", "bom"]) | |
| , (ct, xK_w , spawn "browse \"http://www.bom.gov.au/products/IDR664.loop.shtml\"", "launch a browser with BOM Brisbane weather radar", ["launch", "browser", "weather", "bom"]) | |
| , (sh, xK_m , spawn "browse \"https://www.moneytrackin.com/accounting/transactions/\"", "launch a browser with Moneytrackin Accounting tab open", ["launch", "browser", "money"]) | |
| , (m , xK_grave , spawn "/usr/bin/gedit $HOME/.xmonad/xmonad.hs $HOME/.xmobarrc", "launch gedit with xmonad.hs", ["launch", "editor", "xmonad"]) | |
| , (sh, xK_grave , spawn (terminal' ++ " --working-directory=$HOME/.xmonad -e ghci"), "launch GHCi and load xmonad.hs", ["launch", "ghci", "xmonad"]) | |
| , (m , xK_Home , spawn "nautilus \".\"", "launch nautilus", ["launch", "nautilus", "home"]) | |
| , (sh, xK_Home , spawn "nautilus \"Desktop\"", "launch nautilus at the Desktop", ["launch", "nautilus", "desktop"]) | |
| , (m , xK_Escape, spawn "music", "launch music player", ["launch", "music"]) | |
| , (m , xK_Print , spawn "gnome-screenshot --interactive", "Take a screenshot", ["launch", "screenshot"]) | |
| , (m , xK_o , spawn "xvncviewer oblivion", "Open VNC to a machine called oblivion", ["vnc", "ephox"]) | |
| , (m , xK_b , sendMessage ToggleStruts, "toggle struts", ["toggle", "struts"]) | |
| , (sh, xK_Return, spawn terminal', "launch a terminal", ["launch", "terminal"]) | |
| , (m , xK_p , spawn "exe=`dmenu_path | dmenu -fn -misc-fixed-*-*-*-*-20-*-*-*-*-*-*-* -nb '#000000' -nf '#d0ffd0' -sb '#007000' -sf '#ffffff'` && eval \"exec $exe\"", "launch dmenu", ["dmenu", "menu"]) | |
| , (sh, xK_p , spawn "gmrun", "launch gmrun", ["gmrun", "menu"]) | |
| , (sh, xK_c , kill, "close focused window", ["window", "close"]) | |
| , (m , xK_space , sendMessage NextLayout, "rotate through the available layout algorithms", ["rotate", "layout"]) | |
| , (sh, xK_space , setLayout $ XMonad.layoutHook c, "reset the layouts on the current workspace to default", ["reset", "layout"]) | |
| , (m , xK_n , refresh, "resize viewed windows to the correct size", ["resize", "window"]) | |
| , (m , xK_Tab , windows W.focusDown, "move focus to the next window", ["focus", "window", "down"]) | |
| , (m , xK_j , windows W.focusDown, "move focus to the next window", ["focus", "window", "down"]) | |
| , (m , xK_k , windows W.focusUp, "move focus to the previous window", ["focus", "window", "up"]) | |
| , (sh, xK_Tab , windows W.focusUp, "move focus to the previous window", ["focus", "window", "up"]) | |
| , (m , xK_m , windows W.focusMaster, "move focus to the master window", ["focus", "window", "master"]) | |
| , (m , xK_Return, windows W.swapMaster, "swaps the focused window and the master window", ["focus", "window", "swap", "master"]) | |
| , (sh, xK_j , windows W.swapDown, "swaps the focused window and the next window", ["focus", "window", "swap", "next"]) | |
| , (sh, xK_k , windows W.swapUp, "swaps the focused window and the previous window", ["focus", "window", "swap", "previous"]) | |
| , (m , xK_h , sendMessage Shrink, "shrink the master area", ["shrink", "master"]) | |
| , (m , xK_l , sendMessage Expand, "expand the master area", ["expand", "master"]) | |
| , (m , xK_t , withFocused $ windows . W.sink, "push window back into tiling", ["tile", "unfloat"]) | |
| , (m , xK_comma , sendMessage (IncMasterN 1), "increment the number of windows in the master area", ["increment", "window", "master"]) | |
| , (m , xK_period, sendMessage (IncMasterN (-1)), "decrement the number of windows in the master area", ["decrement", "window", "master"]) | |
| , (sh, xK_q , io (exitWith ExitSuccess), "quit xmonad", ["quit", "xmonad"]) | |
| , (m , xK_q , spawn "xmonad --recompile; xmonad --restart", "restart xmonad", ["restart", "xmonad"]) | |
| ] | |
| ++ | |
| [ | |
| (z .|. m, key, windows $ f i, (if z == shiftMask then "move" else "switch") ++ " to workspace " ++ i, ["window", "move", "switch", "workspace"]) | |
| | (i, key) <- workspaces xConfig `zip` [xK_1 .. xK_9] | |
| , (f, z) <- [(W.greedyView, 0), (W.shift, sh)] | |
| ] | |
| ++ | |
| [ | |
| (z .|. m, key, screenWorkspace s >>= flip whenJust (windows . f), (if z == shiftMask then "move" else "switch") ++ " to screen " ++ show s, ["window", "move", "switch", "screen"]) | |
| | (s, key) <- [0..] `zip` [xK_a, xK_s, xK_d] | |
| , (f, z) <- [(W.view, 0), (W.shift, sh)] | |
| ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment