Personal tools

Xmonad/Config archive/lithis's xmonad.hs

From HaskellWiki

< Xmonad | Config archive(Difference between revisions)
Jump to: navigation, search
(Added my config.)
 
m (Whitespace.)
 
(3 intermediate revisions by one user not shown)
Line 1: Line 1:
 
<haskell>
 
<haskell>
import XMonad
+
import XMonad hiding (Tall)
   
import XMonad.Actions.DwmPromote
+
import XMonad.Actions.Promote
  +
import XMonad.Actions.UpdatePointer
 
import XMonad.Actions.Warp
 
import XMonad.Actions.Warp
 
import XMonad.Hooks.DynamicLog
 
import XMonad.Hooks.DynamicLog
Line 8: Line 8:
 
import XMonad.Hooks.UrgencyHook
 
import XMonad.Hooks.UrgencyHook
 
import XMonad.Layout.LayoutHints
 
import XMonad.Layout.LayoutHints
  +
import XMonad.Layout.HintedTile
 
import XMonad.Layout.NoBorders
 
import XMonad.Layout.NoBorders
 
import XMonad.Layout.Spiral
 
import XMonad.Layout.Spiral
Line 15: Line 16:
 
import XMonad.Prompt.Ssh
 
import XMonad.Prompt.Ssh
 
import XMonad.Util.Run (spawnPipe)
 
import XMonad.Util.Run (spawnPipe)
import System.IO (hPutStrLn)
 
   
 
import qualified Data.Map as M
 
import qualified Data.Map as M
 
import Data.Ratio
 
import Data.Ratio
import Control.Monad
+
import System.IO (hPutStrLn)
+
import GHC.IOBase (Handle)
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 32: Line 32:
 
, manageHook = manageDocks
 
, manageHook = manageDocks
 
, modMask = mod4Mask
 
, modMask = mod4Mask
, borderWidth = 2
+
, borderWidth = 2
 
, keys = \c -> myKeys c `M.union` keys defaultConfig c
 
, keys = \c -> myKeys c `M.union` keys defaultConfig c
, logHook = dynamicLogWithPP hethraelPP
+
, logHook = dynamicLogWithPP (myPP xmobar)
{ ppOutput = hPutStrLn xmobar }
+
>> updatePointer (Relative 1 1)
>> pointerFollowsFocus 1 1
 
 
}
 
}
 
where
 
where
myLayout = layoutHints $ avoidStruts $ smartBorders $ tiled
+
myLayout = layoutHints $ avoidStruts $ smartBorders $ hintedTile Tall
||| Mirror tiled
+
||| hintedTile Wide
 
||| Full
 
||| Full
||| tabbed shrinkText hethraelTheme
+
||| tabbed shrinkText myTheme
 
||| 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
 
delta = 3/100
 
delta = 3/100
   
hethraelPP :: PP
+
myPP :: Handle -> PP
hethraelPP = defaultPP
+
myPP din = defaultPP
 
{ ppCurrent = xmobarColor focusColor ""
 
{ ppCurrent = xmobarColor focusColor ""
 
, ppVisible = xmobarColor lightTextColor ""
 
, ppVisible = xmobarColor lightTextColor ""
 
, ppHiddenNoWindows = xmobarColor lightBackgroundColor ""
 
, ppHiddenNoWindows = xmobarColor lightBackgroundColor ""
, ppUrgent = xmobarColor "#ffc000" ""
+
, ppUrgent = xmobarColor urgentColor ""
 
, ppSep = " · "
 
, ppSep = " · "
 
, ppWsSep = ""
 
, ppWsSep = ""
, ppTitle = xmobarColor lightTextColor "" . shorten 90
+
, ppTitle = xmobarColor lightTextColor ""
  +
, ppOutput = hPutStrLn din
 
}
 
}
   
hethraelTheme :: Theme
+
myTheme :: Theme
hethraelTheme = defaultTheme
+
myTheme = defaultTheme
 
{ activeColor = lightBackgroundColor
 
{ activeColor = lightBackgroundColor
 
, inactiveColor = backgroundColor
 
, inactiveColor = backgroundColor
  +
, urgentColor = backgroundColor
 
, activeBorderColor = textColor
 
, activeBorderColor = textColor
 
, inactiveTextColor = textColor
 
, inactiveTextColor = textColor
, inactiveBorderColor = lightBackgroundColor
+
, urgentTextColor = textColor
  +
, inactiveBorderColor = lightBackgroundColor
  +
, urgentBorderColor = urgentColor
 
, activeTextColor = lightTextColor
 
, activeTextColor = lightTextColor
 
, fontName = myFont
 
, fontName = myFont
 
}
 
}
   
hethraelXPConfig :: XPConfig
+
myXPConfig :: XPConfig
hethraelXPConfig = defaultXPConfig
+
myXPConfig = defaultXPConfig
 
{ font = myFont
 
{ font = myFont
 
, bgColor = backgroundColor
 
, bgColor = backgroundColor
Line 86: Line 87:
 
backgroundColor = "#304520"
 
backgroundColor = "#304520"
 
lightBackgroundColor = "#456030"
 
lightBackgroundColor = "#456030"
  +
urgentColor = "#ffc000"
   
myKeys (XConfig {modMask = modm, workspaces = ws}) = M.fromList $
+
myKeys conf@(XConfig {XMonad.modMask = modMask, workspaces = ws}) = M.fromList $
[ ((modm, xK_Return), dwmpromote)
+
[ ((modMask, xK_Return), promote)
, ((modm, xK_b), sendMessage ToggleStruts)
+
, ((modMask, xK_b), sendMessage ToggleStruts)
, ((modm .|. controlMask, xK_x), shellPrompt hethraelXPConfig)
+
, ((modMask .|. controlMask, xK_x), shellPrompt myXPConfig)
, ((modm .|. controlMask, xK_s), sshPrompt hethraelXPConfig)
+
, ((modMask .|. controlMask, xK_s), sshPrompt myXPConfig)
, ((modm, xK_z), warpToWindow 1 1)
+
, ((modMask, xK_z), warpToWindow 1 1)
, ((modm .|. controlMask, xK_l), spawn "exec xlogo -render -fg `randomdarkcolor` -bg `randomdarkcolor`")
+
, ((modMask, xK_q), recompile True >> restart "xmonad" True)
  +
, ((modMask .|. controlMask, xK_l), spawn "exec xlogo -render -fg `randomdarkcolor` -bg `randomdarkcolor`") -- For testing layouts.
 
]
 
]
 
</haskell>
 
</haskell>

Latest revision as of 19:07, 28 May 2008

import XMonad hiding (Tall)
 
import XMonad.Actions.Promote
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
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 qualified Data.Map as M
import Data.Ratio
import System.IO (hPutStrLn)
import GHC.IOBase (Handle)
 
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 (myPP xmobar)
                 >> updatePointer (Relative 1 1)
        }
        where
            myLayout = layoutHints $ avoidStruts $ smartBorders $ hintedTile Tall
                                 ||| hintedTile Wide
                                 ||| Full
                                 ||| tabbed shrinkText myTheme
                                 ||| spiral (1 % 1)
            hintedTile = HintedTile nmaster delta ratio TopLeft
            nmaster = 1
            ratio   = 1/2
            delta   = 3/100
 
            myPP :: Handle -> PP
            myPP din = defaultPP
                { ppCurrent = xmobarColor focusColor ""
                , ppVisible = xmobarColor lightTextColor ""
                , ppHiddenNoWindows = xmobarColor lightBackgroundColor ""
                , ppUrgent = xmobarColor urgentColor ""
                , ppSep = " · "
                , ppWsSep = ""
                , ppTitle = xmobarColor lightTextColor ""
                , ppOutput = hPutStrLn din
                }
 
            myTheme :: Theme
            myTheme = defaultTheme
                { activeColor = lightBackgroundColor
                , inactiveColor = backgroundColor
                , urgentColor = backgroundColor
                , activeBorderColor = textColor
                , inactiveTextColor = textColor
                , urgentTextColor = textColor
                , inactiveBorderColor = lightBackgroundColor
                , urgentBorderColor = urgentColor
                , activeTextColor = lightTextColor
                , fontName = myFont
                }
 
            myXPConfig :: XPConfig
            myXPConfig = 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"
            urgentColor = "#ffc000"
 
            myKeys conf@(XConfig {XMonad.modMask = modMask, workspaces = ws}) = M.fromList $
                [ ((modMask,                 xK_Return), promote)
                , ((modMask,                 xK_b), sendMessage ToggleStruts)
                , ((modMask .|. controlMask, xK_x), shellPrompt myXPConfig)
                , ((modMask .|. controlMask, xK_s), sshPrompt myXPConfig)
                , ((modMask,                 xK_z), warpToWindow 1 1)
                , ((modMask,                 xK_q), recompile True >> restart "xmonad" True)
                , ((modMask .|. controlMask, xK_l), spawn "exec xlogo -render -fg `randomdarkcolor` -bg `randomdarkcolor`") -- For testing layouts.
                ]