Personal tools

Xmonad/Config archive/lithis's xmonad.hs

From HaskellWiki

< Xmonad | Config archive(Difference between revisions)
Jump to: navigation, search
(Added my config.)
 
(Updated my config.)
Line 3: Line 3:
   
 
import XMonad.Actions.DwmPromote
 
import XMonad.Actions.DwmPromote
  +
import XMonad.Actions.UpdatePointer
 
import XMonad.Actions.Warp
 
import XMonad.Actions.Warp
 
import XMonad.Hooks.DynamicLog
 
import XMonad.Hooks.DynamicLog
Line 8: Line 9:
 
import XMonad.Hooks.UrgencyHook
 
import XMonad.Hooks.UrgencyHook
 
import XMonad.Layout.LayoutHints
 
import XMonad.Layout.LayoutHints
  +
import XMonad.Layout.HintedTile as HT
 
import XMonad.Layout.NoBorders
 
import XMonad.Layout.NoBorders
 
import XMonad.Layout.Spiral
 
import XMonad.Layout.Spiral
Line 20: Line 22:
 
import Data.Ratio
 
import Data.Ratio
 
import Control.Monad
 
import Control.Monad
 
pointerFollowsFocus :: Rational -> Rational -> X ()
 
pointerFollowsFocus h v = withFocused $ \w -> do
 
dpy <- asks display
 
root <- asks theRoot
 
wa <- io $ getWindowAttributes dpy w
 
(sameRoot,_,w',_,_,_,_,_) <- io $ queryPointer dpy root
 
unless (sameRoot && w == w') $
 
io $ warpPointer dpy none w 0 0 0 0
 
(fraction h (wa_width wa)) (fraction v (wa_height wa))
 
where fraction x y = floor (x * fromIntegral y)
 
   
 
main :: IO ()
 
main :: IO ()
Line 46: Line 37:
 
, logHook = dynamicLogWithPP hethraelPP
 
, logHook = dynamicLogWithPP hethraelPP
 
{ ppOutput = hPutStrLn xmobar }
 
{ ppOutput = hPutStrLn xmobar }
>> pointerFollowsFocus 1 1
+
>> updatePointer (Relative 1 1)
 
}
 
}
 
where
 
where
myLayout = layoutHints $ avoidStruts $ smartBorders $ tiled
+
myLayout = layoutHints $ avoidStruts $ smartBorders $ hintedTile HT.Tall
||| Mirror tiled
+
||| hintedTile Wide
 
||| Full
 
||| Full
 
||| tabbed shrinkText hethraelTheme
 
||| tabbed shrinkText hethraelTheme
 
||| spiral (1 % 1)
 
||| spiral (1 % 1)
tiled = Tall nmaster delta ratio
+
hintedTile = HintedTile nmaster delta ratio TopLeft
 
nmaster = 1
 
nmaster = 1
 
ratio = 1/2
 
ratio = 1/2
Line 104: Line 95:
 
, ((modm .|. controlMask, xK_s), sshPrompt hethraelXPConfig)
 
, ((modm .|. controlMask, xK_s), sshPrompt hethraelXPConfig)
 
, ((modm, xK_z), warpToWindow 1 1)
 
, ((modm, xK_z), warpToWindow 1 1)
, ((modm .|. controlMask, xK_l), spawn "exec xlogo -render -fg `randomdarkcolor` -bg `randomdarkcolor`")
+
, ((modm .|. controlMask, xK_l), spawn "exec xlogo -render -fg `randomdarkcolor` -bg `randomdarkcolor`") -- For testing layouts.
 
]
 
]
 
</haskell>
 
</haskell>

Revision as of 19:48, 28 March 2008

import XMonad
 
import XMonad.Actions.DwmPromote
import XMonad.Actions.UpdatePointer
import XMonad.Actions.Warp
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.UrgencyHook
import XMonad.Layout.LayoutHints
import XMonad.Layout.HintedTile as HT
import XMonad.Layout.NoBorders
import XMonad.Layout.Spiral
import XMonad.Layout.Tabbed
import XMonad.Prompt
import XMonad.Prompt.Shell
import XMonad.Prompt.Ssh
import XMonad.Util.Run (spawnPipe)
import System.IO (hPutStrLn)
 
import qualified Data.Map as M
import Data.Ratio
import Control.Monad
 
main :: IO ()
main = do
    xmobar <- spawnPipe "xmobar"
    xmonad $ withUrgencyHook NoUrgencyHook $ defaultConfig
        { normalBorderColor  = backgroundColor
        , focusedBorderColor = focusColor
        , terminal = "$XTERMCMD"
        , layoutHook = myLayout
        , manageHook = manageDocks
        , modMask = mod4Mask
	, borderWidth = 2
        , keys = \c -> myKeys c `M.union` keys defaultConfig c
        , logHook = dynamicLogWithPP hethraelPP
            { ppOutput = hPutStrLn xmobar }
             >> updatePointer (Relative 1 1)
        }
        where
            myLayout = layoutHints $ avoidStruts $ smartBorders $ hintedTile HT.Tall
                                 ||| hintedTile Wide
                                 ||| Full
                                 ||| tabbed shrinkText hethraelTheme
                                 ||| spiral (1 % 1)
            hintedTile = HintedTile nmaster delta ratio TopLeft
            nmaster = 1
            ratio   = 1/2
            delta   = 3/100
 
            hethraelPP :: PP
            hethraelPP = defaultPP
                { ppCurrent = xmobarColor focusColor ""
                , ppVisible = xmobarColor lightTextColor ""
                , ppHiddenNoWindows = xmobarColor lightBackgroundColor ""
                , ppUrgent = xmobarColor "#ffc000" ""
                , ppSep = " · "
                , ppWsSep = ""
                , ppTitle = xmobarColor lightTextColor "" . shorten 90
                }
 
            hethraelTheme :: Theme
            hethraelTheme = defaultTheme
                { activeColor = lightBackgroundColor
                , inactiveColor = backgroundColor
                , activeBorderColor = textColor
                , inactiveTextColor = textColor
                , inactiveBorderColor  = lightBackgroundColor
                , activeTextColor = lightTextColor
                , fontName = myFont
                }
 
            hethraelXPConfig :: XPConfig
            hethraelXPConfig = defaultXPConfig
                { font        = myFont
                , bgColor     = backgroundColor
                , fgColor     = textColor
                , fgHLight    = lightTextColor
                , bgHLight    = lightBackgroundColor
                , borderColor = lightBackgroundColor
                }
 
            myFont = "xft:DejaVu Sans:size=10"
            focusColor = "#60ff45"
            textColor = "#c0c0a0"
            lightTextColor = "#fffff0"
            backgroundColor = "#304520"
            lightBackgroundColor = "#456030"
 
            myKeys (XConfig {modMask = modm, workspaces = ws}) = M.fromList $
                [ ((modm,                 xK_Return), dwmpromote)
                , ((modm,                 xK_b), sendMessage ToggleStruts)
                , ((modm .|. controlMask, xK_x), shellPrompt hethraelXPConfig)
                , ((modm .|. controlMask, xK_s), sshPrompt hethraelXPConfig)
                , ((modm,                 xK_z), warpToWindow 1 1)
                , ((modm .|. controlMask, xK_l), spawn "exec xlogo -render -fg `randomdarkcolor` -bg `randomdarkcolor`") -- For testing layouts.
                ]