Skip to content

Instantly share code, notes, and snippets.

@ravishi
Last active October 13, 2015 06:37
Show Gist options
  • Save ravishi/4154309 to your computer and use it in GitHub Desktop.
Save ravishi/4154309 to your computer and use it in GitHub Desktop.
My XMonad configuration
-----------------------------------------------------------------------------
-- |
-- Copyright : (c) Dirley Rodrigues 2012
-- License : BSD3-style (see LICENSE)
--
-- Maintainer : [email protected]
-- Stability : experimental
--
-- This module specifies my personal configuration values for xmonad
-- and declares it's main function.
--
-----------------------------------------------------------------------------
import XMonad
import XMonad.Actions.DwmPromote (dwmpromote)
import XMonad.Actions.CopyWindow (copyToAll)
import XMonad.Config.Gnome (gnomeConfig)
import XMonad.Hooks.ManageDocks (avoidStruts)
import XMonad.Hooks.ManageHelpers (isDialog, doCenterFloat, isFullscreen, doFullFloat)
import XMonad.Layout.Grid
import XMonad.Layout.IM
import XMonad.Layout.Named (named)
import XMonad.Layout.NoBorders (noBorders, smartBorders)
import XMonad.Layout.PerWorkspace (onWorkspace)
import XMonad.Layout.Reflect (reflectHoriz)
import XMonad.Util.EZConfig (additionalKeysP)
import XMonad.Hooks.SetWMName (setWMName)
import XMonad.Hooks.ManageDocks (manageDocks)
import Control.Monad (liftM2, filterM)
import Data.Ratio ((%))
import System.IO
import qualified Data.Map as M
import qualified XMonad.StackSet as W
myWorkspaces = ["1:dev", "2:web", "3:im"] ++ map show [4..8] ++ ["9:full"]
myManageHook = composeAll
[ (className =? "Google-chrome") --> viewShift "2:web"
, (className =? "Pidgin") --> doShift "3:im"
, (className =? "Vlc") --> viewShift "9:full"
, (className =? "Unity-2d-panel") --> doFloat
, (className =? "Unity-2d-launcher") --> doFloat
, isDialog --> doCenterFloat
, isFullscreen --> (doF W.focusDown <+> doFullFloat)]
where
viewShift = doF . liftM2 (.) W.greedyView W.shift
-- my custom layout. i dont know where this came from, but i'm used to it.
basicLayout = Tall nmaster delta ratio where
nmaster = 1
delta = 3/100
ratio = 1/2
tallLayout = named "tall" $ avoidStruts $ basicLayout
wideLayout = named "wide" $ avoidStruts $ Mirror basicLayout
singleLayout = named "single" $ avoidStruts $ noBorders Full
fullscreenLayout = named "fullscreen" $ noBorders Full
imLayout = named "im" $ avoidStruts $ reflectHoriz $ withIM ratio roster chatLayout
where
chatLayout = Grid
ratio = 1%6
roster = And (ClassName "Pidgin") (Role "buddy_list")
myLayoutHook = smartBorders $ fullscreen $ im $ normal
where
normal = tallLayout ||| wideLayout ||| singleLayout
fullscreen = onWorkspace "9:full" fullscreenLayout
im = onWorkspace "3:im" imLayout
-- keys configuration. i'm trying to keep it small.
myKeys :: XConfig Layout -> M.Map (KeyMask, KeySym) (X ())
myKeys conf@(XConfig {XMonad.modMask = modMask}) = M.fromList $
[ ((mod1Mask, xK_Tab), windows W.focusDown)
, ((modMask, xK_KP_F4), kill)
, ((modMask, xK_KP_Enter), dwmpromote)
]
------------------------------------------------------------------------
-- Startup hook
-- Perform an arbitrary action each time xmonad starts or is restarted
-- with mod-q. Used by, e.g., XMonad.Layout.PerWorkspace to initialize
-- per-workspace layout choices.
--
myStartupHook = setWMName "LG3D"
------------------------------------------------------------------------
-- Finally, run xmonad like we set up.
main = do xmonad myConfig
------------------------------------------------------------------------
-- Combine all configuration.
myConfig = gnomeConfig {
-- simple stuff
terminal = "gnome-terminal",
-- set the Windows key as the mod key
modMask = mod4Mask,
workspaces = myWorkspaces,
-- border configuration
-- the border colors are currently based on the ir_black theme
normalBorderColor = "#7c7c7c",
focusedBorderColor = "#ffb6b0",
borderWidth = 0,
-- hooks and layouts
layoutHook = myLayoutHook,
manageHook = manageDocks <+> myManageHook,
startupHook = myStartupHook,
keys = myKeys <+> keys gnomeConfig
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment