Personal tools

Xmonad/Config archive/Eric Mertens' xmonad.hs

From HaskellWiki

< Xmonad | Config archive(Difference between revisions)
Jump to: navigation, search
 
Line 1: Line 1:
 
<haskell>
 
<haskell>
  +
-- xmonad.hs
 
import XMonad
 
import XMonad
import XMonad.Actions.RotView ( rotView )
+
import XMonad.Actions.RotView ( rotView )
import XMonad.Config ( defaultConfig )
+
import XMonad.Hooks.DynamicLog ( PP(..), dynamicLogWithPP, dzenColor, wrap, defaultPP )
import XMonad.Core ( xmonad )
+
import XMonad.Layouts ( (|||), Full(..) )
import XMonad.Hooks.DynamicLog
 
import XMonad.Layouts ( (|||), Full(..) )
 
 
import XMonad.Layout.LayoutHints ( layoutHints )
 
import XMonad.Layout.LayoutHints ( layoutHints )
import XMonad.Layout.TilePrime ( TilePrime(TilePrime) )
+
import XMonad.Layout.TilePrime ( TilePrime(..) )
import XMonad.Prompt
+
import XMonad.Prompt ( defaultXPConfig, XPConfig(..), XPPosition(..) )
import XMonad.Prompt.Shell
+
import XMonad.Prompt.Shell ( shellPrompt )
  +
import XMonad.Util.Run
   
 
import qualified Data.Map as Map
 
import qualified Data.Map as Map
 
import Data.Ratio
 
import Data.Ratio
 
import Graphics.X11
 
import Graphics.X11
  +
import System.IO
   
main = xmonad $ defaultConfig
+
statusBarCmd= "dzen2 -e '' -w 1040 -ta l -fg white -bg \"#222222\" -fn \"-xos4-terminus-medium-r-normal--16-160-72-72-c-80-iso8859-1\""
{ borderWidth = 2
 
, normalBorderColor = "#cccccc"
 
, focusedBorderColor = "#cd8b00"
 
, terminal = "urxvtc"
 
, workspaces = ["main","net","www"]
 
++ map show [4..9]
 
, defaultGaps = [(18,0,0,0)]
 
, modMask = mod4Mask
 
, logHook = dynamicLogWithPP myPP
 
, mouseBindings = myMouse `joinMap`
 
mouseBindings defaultConfig
 
, keys = myKeys `joinMap` keys defaultConfig
 
, layoutHook = Layout
 
$ TilePrime 1 (3%100) (1%2) False
 
||| TilePrime 1 (3%100) (1%2) True
 
||| layoutHints Full
 
}
 
   
joinMap m n c = m c `Map.union` n c
+
main = do din <- spawnPipe statusBarCmd
  +
xmonad $ defaultConfig
  +
{ borderWidth = 2
  +
, normalBorderColor = "#666666"
  +
, focusedBorderColor = "#cd8b00"
  +
, terminal = "urxvtc"
  +
, workspaces = ["main","net","www"]
  +
++ map show [4..9]
  +
, defaultGaps = [(18,0,0,0)]
  +
, modMask = mod4Mask
  +
, logHook = dynamicLogWithPP $ myPP din
  +
, mouseBindings = \c -> myMouse `Map.union`
  +
mouseBindings defaultConfig c
  +
, keys = \c -> myKeys `Map.union`
  +
keys defaultConfig c
  +
, layoutHook = Layout
  +
$ TilePrime 1 (3%100) (1%2) False
  +
||| TilePrime 1 (3%100) (1%2) True
  +
||| layoutHints Full
  +
}
   
myKeys (XConfig {modMask = modm}) = Map.fromList $
+
myKeys = Map.fromList $
[ ((modm, xK_p), shellPrompt myPromptConfig)
+
[ ((mod4Mask, xK_p), shellPrompt myPromptConfig)
 
, ((0, 0x1008ff12), spawn "amixer -q set Front toggle")
 
, ((0, 0x1008ff12), spawn "amixer -q set Front toggle")
 
, ((0, 0x1008ff13), spawn "amixer -q set PCM 2dB+")
 
, ((0, 0x1008ff13), spawn "amixer -q set PCM 2dB+")
Line 29: Line 31:
 
}
 
}
   
myMouse (XConfig {XMonad.modMask = modMask}) = Map.fromList $
+
myMouse = Map.fromList $
[ ((modMask, button4), (\_ -> rotView True))
+
[ ((mod4Mask, button4), (\_ -> rotView True))
, ((modMask, button5), (\_ -> rotView False))
+
, ((mod4Mask, button5), (\_ -> rotView False))
 
]
 
]
   
myPP = defaultPP
+
myPP h = defaultPP
{ ppCurrent = dzenColor "white" "#222222" . pad
+
{ ppCurrent = dzenColor "white" "#cd8b00" . pad
, ppVisible = dzenColor "black" "#999999" . pad
+
, ppVisible = dzenColor "white" "#666666" . pad
 
, ppHidden = dzenColor "black" "#cccccc" . pad
 
, ppHidden = dzenColor "black" "#cccccc" . pad
, ppHiddenNoWindows = const ""
+
, ppHiddenNoWindows = dzenColor "#999999" "#cccccc" . pad
, ppWsSep = ""
+
, ppWsSep = dzenColor "#bbbbbb" "#cccccc" "^r(1x18)"
, ppSep = ""
+
, ppSep = dzenColor "#bbbbbb" "#cccccc" "^r(1x18)"
 
, ppLayout = dzenColor "black" "#cccccc" .
 
, ppLayout = dzenColor "black" "#cccccc" .
 
(\ x -> case x of
 
(\ x -> case x of
Line 52: Line 54:
 
)
 
)
 
, ppTitle = (' ':) . escape
 
, ppTitle = (' ':) . escape
  +
, ppOutput = hPutStrLn h
 
}
 
}
 
where
 
where

Latest revision as of 08:29, 7 November 2007

-- xmonad.hs
import XMonad
import XMonad.Actions.RotView    ( rotView )
import XMonad.Hooks.DynamicLog   ( PP(..), dynamicLogWithPP, dzenColor, wrap, defaultPP )
import XMonad.Layouts            ( (|||), Full(..) )
import XMonad.Layout.LayoutHints ( layoutHints )
import XMonad.Layout.TilePrime   ( TilePrime(..) )
import XMonad.Prompt             ( defaultXPConfig, XPConfig(..), XPPosition(..) )
import XMonad.Prompt.Shell       ( shellPrompt )
import XMonad.Util.Run
 
import qualified Data.Map as Map
import Data.Ratio
import Graphics.X11
import System.IO
 
statusBarCmd= "dzen2 -e '' -w 1040 -ta l -fg white -bg \"#222222\" -fn \"-xos4-terminus-medium-r-normal--16-160-72-72-c-80-iso8859-1\""
 
main = do din <- spawnPipe statusBarCmd
          xmonad $ defaultConfig
                     { borderWidth        = 2
                     , normalBorderColor  = "#666666"
                     , focusedBorderColor = "#cd8b00"
                     , terminal           = "urxvtc"
                     , workspaces         = ["main","net","www"]
                                            ++ map show [4..9]
                     , defaultGaps        = [(18,0,0,0)]
                     , modMask            = mod4Mask
                     , logHook            = dynamicLogWithPP $ myPP din
                     , mouseBindings      = \c -> myMouse `Map.union`
                                                  mouseBindings defaultConfig c
                     , keys               = \c -> myKeys `Map.union`
                                                  keys defaultConfig c
                     , layoutHook         = Layout
                                               $ TilePrime 1 (3%100) (1%2) False
                                             ||| TilePrime 1 (3%100) (1%2) True
                                             ||| layoutHints Full
                     }
 
myKeys = Map.fromList $
  [ ((mod4Mask, xK_p), shellPrompt myPromptConfig)
  , ((0, 0x1008ff12), spawn "amixer -q set Front toggle")
  , ((0, 0x1008ff13), spawn "amixer -q set PCM 2dB+")
  , ((0, 0x1008ff11), spawn "amixer -q set PCM 2dB-")
  ]
 
myPromptConfig = defaultXPConfig
                   { position = Top
                   , promptBorderWidth = 0
                   }
 
myMouse = Map.fromList $
    [ ((mod4Mask, button4), (\_ -> rotView True))
    , ((mod4Mask, button5), (\_ -> rotView False))
    ]
 
myPP h = defaultPP
         { ppCurrent  = dzenColor "white" "#cd8b00" . pad
         , ppVisible  = dzenColor "white" "#666666" . pad
         , ppHidden   = dzenColor "black" "#cccccc" . pad
         , ppHiddenNoWindows = dzenColor "#999999" "#cccccc" . pad
         , ppWsSep    = dzenColor "#bbbbbb" "#cccccc" "^r(1x18)"
         , ppSep      = dzenColor "#bbbbbb" "#cccccc" "^r(1x18)"
         , ppLayout   = dzenColor "black" "#cccccc" .
                        (\ x -> case x of
                                  "TilePrime Horizontal" ->
                                    " ^i(/home/emertens/images/tile_horz.xpm) "
                                  "TilePrime Vertical"   ->
                                    " ^i(/home/emertens/images/tile_vert.xpm) "
                                  "Hinted Full"          ->
                                    " ^i(/home/emertens/images/fullscreen.xpm) "
                                  _                      -> pad x
                        )
         , ppTitle    = (' ':) . escape
         , ppOutput   = hPutStrLn h
         }
  where
  escape = concatMap (\x -> if x == '^' then "^^" else [x])
  pad = wrap " " " "