Personal tools

Xmonad/Config archive/gray hemp's xmonad.hs

From HaskellWiki

< Xmonad | Config archive(Difference between revisions)
Jump to: navigation, search
 
(2 intermediate revisions by one user not shown)
Line 3: Line 3:
 
-- uses icons from dzen.geekmode.org
 
-- uses icons from dzen.geekmode.org
 
import XMonad
 
import XMonad
  +
import XMonad.Core
   
 
import XMonad.Prompt
 
import XMonad.Prompt
Line 14: Line 15:
 
import XMonad.Hooks.DynamicLog
 
import XMonad.Hooks.DynamicLog
 
import XMonad.Hooks.ManageDocks
 
import XMonad.Hooks.ManageDocks
  +
import XMonad.Hooks.ManageHelpers
 
import XMonad.Hooks.UrgencyHook
 
import XMonad.Hooks.UrgencyHook
  +
import XMonad.Hooks.FadeInactive
   
 
import qualified Data.Map as M
 
import qualified Data.Map as M
  +
import Graphics.X11.Xlib
 
import XMonad.Util.Run
 
import XMonad.Util.Run
   
 
main = do
 
main = do
 
myStatusBarPipe <- spawnPipe myStatusBar
 
myStatusBarPipe <- spawnPipe myStatusBar
  +
spawn "hsetroot && xcompmgr"
  +
spawn myCPUBar
  +
spawn myBatteryBar
 
spawn myTimeBar
 
spawn myTimeBar
  +
spawn myXxkbBar
  +
spawn myXsetRate
 
xmonad $ myUrgencyHook $ defaultConfig {
 
xmonad $ myUrgencyHook $ defaultConfig {
 
terminal = myTerminal,
 
terminal = myTerminal,
Line 29: Line 38:
 
modMask = myModMask,
 
modMask = myModMask,
 
keys = myKeys,
 
keys = myKeys,
manageHook = manageDocks <+> manageHook defaultConfig,
+
manageHook = myManageHook <+> manageDocks <+> manageHook defaultConfig,
 
layoutHook = avoidStruts $ myLayoutHook,
 
layoutHook = avoidStruts $ myLayoutHook,
logHook = dynamicLogWithPP $ myDzenPP myStatusBarPipe
+
logHook = do dynamicLogWithPP $ myDzenPP myStatusBarPipe
  +
myFadingHook
 
}
 
}
   
Line 39: Line 48:
   
 
-- Paths
 
-- Paths
myBitmapsPath = "/home/user/.dzen/bitmaps/"
+
myBitmapsPath = "/home/gray/.dzen/bitmaps/"
   
 
-- Colors
 
-- Colors
myFgColor = "#d0d3e6"
+
myBgBgColor = "black"
myBgColor = "#363743"
+
myFgColor = "gray80"
  +
myBgColor = "gray20"
   
myHighlightedFgColor = "#ffffff"
+
myHighlightedFgColor = "white"
myHighlightedBgColor = "#60626b"
+
myHighlightedBgColor = "gray40"
   
myActiveBorderColor = "#d0d3e6"
+
myActiveBorderColor = "gray20"
myInactiveBorderColor = "#80828e"
+
myInactiveBorderColor = "gray20"
   
myLayoutColor = "#a0a3b0"
+
myCurrentWsFgColor = "white"
+
myCurrentWsBgColor = "gray40"
myCurrentWsFgColor = "#ffffff"
+
myVisibleWsFgColor = "gray80"
myCurrentWsBgColor = "#80828e"
+
myVisibleWsBgColor = "gray20"
myVisibleWsFgColor = "#ffffff"
+
myHiddenWsFgColor = "gray80"
myVisibleWsBgColor = "#60626b"
+
myHiddenEmptyWsFgColor = "gray50"
myHiddenWsFgColor = "#d0d3e6"
+
myUrgentWsBgColor = "brown"
myHiddenEmptyWsFgColor = "#80828e"
+
myTitleFgColor = "white"
myUrgentWsBgColor = "#725050"
 
myTitleFgColor = "#ffffff"
 
 
myUrgencyHintFgColor = "#ffffff"
 
myUrgencyHintBgColor = "#7e5250"
 
   
  +
myUrgencyHintFgColor = "white"
  +
myUrgencyHintBgColor = "brown"
   
 
-- Bars
 
-- Bars
myDzenBarGeneralOptions = " -ta l -fn '" ++ myFont ++ "' -fg '" ++ myFgColor ++ "' -bg '" ++ myBgColor ++ "'"
+
myDzenBarGeneralOptions = "-h 15 -fn '" ++ myFont ++ "' -fg '" ++ myFgColor ++
  +
"' -bg '" ++ myBgColor ++ "'"
   
myStatusBar = "dzen2 -w 1134 " ++ myDzenBarGeneralOptions
+
myStatusBar = "dzen2 -w 956 -ta l " ++ myDzenBarGeneralOptions
myTimeBar = "conky -c ~/.conky_time | dzen2 -x 1134 " ++ myDzenBarGeneralOptions
+
myCPUBar = "conky -c ~/.conky_cpu | sh | dzen2 -x 956 -w 90 -ta l " ++
  +
myDzenBarGeneralOptions
  +
myBatteryBar = "conky -c ~/.conky_battery | sh | dzen2 -x 1046 -w 63 -ta l " ++
  +
myDzenBarGeneralOptions
  +
myTimeBar = "conky -c ~/.conky_time | dzen2 -x 1109 -w 156 -ta c " ++
  +
myDzenBarGeneralOptions
  +
myXxkbBar = "xxkb" -- configuration in ~/.xxkbrc
  +
myXsetRate = "xset r rate 250 30"
   
 
-- Prefered terminal
 
-- Prefered terminal
Line 89: Line 100:
   
 
-- Add new and/or redefine key bindings
 
-- Add new and/or redefine key bindings
newKeys (XConfig {XMonad.modMask = modm}) = [
+
newKeys conf@(XConfig {XMonad.modMask = modm}) = [
 
-- Use shellPrompt instead of default dmenu
 
-- Use shellPrompt instead of default dmenu
 
((modm, xK_p), shellPrompt myXPConfig),
 
((modm, xK_p), shellPrompt myXPConfig),
 
-- Do not leave useless conky, dzen and xxkb after restart
 
-- Do not leave useless conky, dzen and xxkb after restart
((modm, xK_q), spawn "killall conky dzen2; xmonad --recompile; xmonad --restart"),
+
((modm, xK_q), spawn "killall conky dzen2 xxkb xcompmgr; xmonad --recompile; xmonad --restart"),
 
-- ResizableTall key bindings
 
-- ResizableTall key bindings
 
((modm, xK_a), sendMessage MirrorShrink),
 
((modm, xK_a), sendMessage MirrorShrink),
Line 99: Line 110:
 
-- Manual page prompt
 
-- Manual page prompt
 
((modm, xK_o), manPrompt myXPConfig),
 
((modm, xK_o), manPrompt myXPConfig),
((modm, xK_u), focusUrgent)
+
((modm, xK_u), focusUrgent),
  +
-- Make a screeshot
  +
((0, xK_Print), spawn "scrot -e 'mv $f ~/tmp/'"),
  +
((controlMask, xK_Print), spawn "sleep 0.2; scrot -s -e 'mv $f ~/tmp/'")
 
]
 
]
   
 
-- Workspaces names
 
-- Workspaces names
 
myWorkspaces = [
 
myWorkspaces = [
supWsNum "1" "dev",
+
supWsNum "1" "dv",
supWsNum "2" "web",
+
supWsNum "2" "wb",
supWsNum "3" "con",
+
supWsNum "3" "tr",
supWsNum "4" "msg",
+
supWsNum "4" "ms",
supWsNum "5" "msc",
+
supWsNum "5" "mn",
supWsNum "6" "tmp",
+
supWsNum "6" "dc",
" 7 ", " 8 ", " 9 "
+
supWsNum "7" "tm",
  +
supWsNum "8" "",
  +
supWsNum "9" ""
 
]
 
]
 
where
 
where
supWsNum wsNum wsName = "^p(;_TOP)^fn(" ++ mySmallFont ++ ") " ++ wsNum ++ " ^fn()^p()" ++ wsName ++ " "
+
supWsNum wsName wsNum =" " ++ wsName ++ "^p(;_TOP)^fn(" ++ mySmallFont ++ ")" ++ wsNum ++ " ^fn()^p()"
   
 
-- Dzen config
 
-- Dzen config
 
myDzenPP h = defaultPP {
 
myDzenPP h = defaultPP {
 
ppOutput = hPutStrLn h,
 
ppOutput = hPutStrLn h,
ppSep = " ",
+
ppSep = "",
 
ppWsSep = "",
 
ppWsSep = "",
 
ppCurrent = wrapFgBg myCurrentWsFgColor myCurrentWsBgColor,
 
ppCurrent = wrapFgBg myCurrentWsFgColor myCurrentWsBgColor,
Line 126: Line 137:
 
ppUrgent = wrapBg myUrgentWsBgColor,
 
ppUrgent = wrapBg myUrgentWsBgColor,
 
ppTitle = (\x -> " " ++ wrapFg myTitleFgColor x),
 
ppTitle = (\x -> " " ++ wrapFg myTitleFgColor x),
ppLayout = dzenColor myLayoutColor "" .
+
ppLayout = dzenColor myFgColor"" .
 
(\x -> case x of
 
(\x -> case x of
 
"ResizableTall" -> wrapBitmap "rob/tall.xbm"
 
"ResizableTall" -> wrapBitmap "rob/tall.xbm"
Line 137: Line 148:
 
wrapFg color content = wrap ("^fg(" ++ color ++ ")") "^fg()" content
 
wrapFg color content = wrap ("^fg(" ++ color ++ ")") "^fg()" content
 
wrapBg color content = wrap ("^bg(" ++ color ++ ")") "^bg()" content
 
wrapBg color content = wrap ("^bg(" ++ color ++ ")") "^bg()" content
wrapBitmap bitmap = "^i(" ++ myBitmapsPath ++ bitmap ++ ")"
+
wrapBitmap bitmap = "^p(5)^i(" ++ myBitmapsPath ++ bitmap ++ ")^p(5)"
  +
  +
-- Fading hook
  +
myFadingHook = fadeInactiveLogHook fadeAmount
  +
where fadeAmount = 0.85
   
 
-- Define a combination of layouts
 
-- Define a combination of layouts
myLayoutHook = smartBorders $ (tiled ||| Mirror tiled ||| Full) -- The only window w/o borders
+
myLayoutHook = smartBorders $ (tiled ||| Mirror tiled ||| Full)
  +
-- The only window w/o borders
 
where
 
where
 
tiled = ResizableTall nmaster delta ratio []
 
tiled = ResizableTall nmaster delta ratio []
Line 157: Line 168:
 
"-fn", "" ++ myFont ++ ""
 
"-fn", "" ++ myFont ++ ""
 
],
 
],
duration = seconds 7 -- with ghc-6.8* can use (7 `seconds`)
+
duration = (7 `seconds`)
 
}
 
}
  +
  +
-- Window rules
  +
myManageHook = composeAll . concat $ [
  +
[isDialog --> doFloat],
  +
[className =? c --> doFloat | c <- myCFloats],
  +
[title =? t --> doFloat | t <- myTFloats],
  +
[resource =? r --> doFloat | r <- myRFloats],
  +
[resource =? i --> doIgnore | i <- myIgnores]
  +
]
  +
where
  +
myCFloats = ["Xmessage"]
  +
myTFloats = ["Save As...", "Save File", "Options"]
  +
myRFloats = []
  +
myIgnores = ["XXkb"]
 
</haskell>
 
</haskell>

Latest revision as of 10:30, 7 September 2010

-- dzen2 plus conky config with urgency for xmonad-0.9*
-- uses icons from dzen.geekmode.org
import XMonad
import XMonad.Core
 
import XMonad.Prompt
import XMonad.Prompt.Shell
import XMonad.Prompt.Man
 
import XMonad.Layout
import XMonad.Layout.NoBorders
import XMonad.Layout.ResizableTile
 
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.ManageHelpers
import XMonad.Hooks.UrgencyHook
import XMonad.Hooks.FadeInactive
 
import qualified Data.Map as M
import Graphics.X11.Xlib
import XMonad.Util.Run
 
main = do
  myStatusBarPipe <- spawnPipe myStatusBar
  spawn "hsetroot && xcompmgr"
  spawn myCPUBar
  spawn myBatteryBar
  spawn myTimeBar
  spawn myXxkbBar
  spawn myXsetRate
  xmonad $ myUrgencyHook $ defaultConfig {
    terminal = myTerminal,
    normalBorderColor = myInactiveBorderColor,
    focusedBorderColor = myActiveBorderColor,
    workspaces = myWorkspaces,
    modMask = myModMask,
    keys = myKeys,
    manageHook = myManageHook <+> manageDocks <+> manageHook defaultConfig,
    layoutHook = avoidStruts $ myLayoutHook,
    logHook = do dynamicLogWithPP $ myDzenPP myStatusBarPipe
                 myFadingHook
    }
 
-- Fonts
myFont = "xft:monospace:size=8"
mySmallFont = "xft:monospace:size=5"
 
-- Paths
myBitmapsPath = "/home/gray/.dzen/bitmaps/"
 
-- Colors
myBgBgColor = "black"
myFgColor = "gray80"
myBgColor = "gray20"
 
myHighlightedFgColor = "white"
myHighlightedBgColor = "gray40"
 
myActiveBorderColor = "gray20"
myInactiveBorderColor = "gray20"
 
myCurrentWsFgColor = "white"
myCurrentWsBgColor = "gray40"
myVisibleWsFgColor = "gray80"
myVisibleWsBgColor = "gray20"
myHiddenWsFgColor = "gray80"
myHiddenEmptyWsFgColor = "gray50"
myUrgentWsBgColor = "brown"
myTitleFgColor = "white"
 
myUrgencyHintFgColor = "white"
myUrgencyHintBgColor = "brown"
 
-- Bars
myDzenBarGeneralOptions = "-h 15 -fn '" ++ myFont ++ "' -fg '" ++ myFgColor ++
                          "' -bg '" ++ myBgColor ++ "'"
 
myStatusBar = "dzen2 -w 956 -ta l " ++ myDzenBarGeneralOptions
myCPUBar = "conky -c ~/.conky_cpu | sh | dzen2 -x 956 -w 90 -ta l " ++
           myDzenBarGeneralOptions
myBatteryBar = "conky -c ~/.conky_battery | sh | dzen2 -x 1046 -w 63 -ta l " ++
               myDzenBarGeneralOptions
myTimeBar = "conky -c ~/.conky_time | dzen2 -x 1109 -w 156 -ta c " ++
            myDzenBarGeneralOptions
myXxkbBar = "xxkb" -- configuration in ~/.xxkbrc
myXsetRate = "xset r rate 250 30"
 
-- Prefered terminal
myTerminal = "urxvt"
 
-- Rebind Mod to Windows key
myModMask = mod4Mask
 
-- Prompt config
myXPConfig = defaultXPConfig {
  position = Bottom,
  promptBorderWidth = 0,
  font = myFont,
  height = 15,
  bgColor = myBgColor,
  fgColor = myFgColor,
  fgHLight = myHighlightedFgColor,
  bgHLight = myHighlightedBgColor
  }
 
-- Union default and new key bindings
myKeys x  = M.union (M.fromList (newKeys x)) (keys defaultConfig x)
 
-- Add new and/or redefine key bindings
newKeys conf@(XConfig {XMonad.modMask = modm}) = [
  -- Use shellPrompt instead of default dmenu
  ((modm, xK_p), shellPrompt myXPConfig),
  -- Do not leave useless conky, dzen and xxkb after restart
  ((modm, xK_q), spawn "killall conky dzen2 xxkb xcompmgr; xmonad --recompile; xmonad --restart"),
  -- ResizableTall key bindings
  ((modm, xK_a), sendMessage MirrorShrink),
  ((modm, xK_z), sendMessage MirrorExpand),
  -- Manual page prompt
  ((modm, xK_o), manPrompt myXPConfig),
  ((modm, xK_u), focusUrgent),
  -- Make a screeshot
  ((0,           xK_Print), spawn "scrot -e 'mv $f ~/tmp/'"),
  ((controlMask, xK_Print), spawn "sleep 0.2; scrot -s -e 'mv $f ~/tmp/'")
  ]
 
-- Workspaces names
myWorkspaces = [
  supWsNum "1" "dv",
  supWsNum "2" "wb",
  supWsNum "3" "tr",
  supWsNum "4" "ms",
  supWsNum "5" "mn",
  supWsNum "6" "dc",
  supWsNum "7" "tm",
  supWsNum "8" "",
  supWsNum "9" ""
  ]
  where
    supWsNum wsName wsNum =" " ++ wsName ++  "^p(;_TOP)^fn(" ++ mySmallFont  ++ ")" ++ wsNum ++ "  ^fn()^p()"
 
-- Dzen config
myDzenPP h = defaultPP {
  ppOutput = hPutStrLn h,
  ppSep = "",
  ppWsSep = "",
  ppCurrent = wrapFgBg myCurrentWsFgColor myCurrentWsBgColor,
  ppVisible = wrapFgBg myVisibleWsFgColor myVisibleWsBgColor,
  ppHidden = wrapFg myHiddenWsFgColor,
  ppHiddenNoWindows = wrapFg myHiddenEmptyWsFgColor,
  ppUrgent = wrapBg myUrgentWsBgColor,
  ppTitle = (\x -> " " ++ wrapFg myTitleFgColor x),
  ppLayout  = dzenColor myFgColor"" .
                (\x -> case x of
                    "ResizableTall" -> wrapBitmap "rob/tall.xbm"
                    "Mirror ResizableTall" -> wrapBitmap "rob/mtall.xbm"
                    "Full" -> wrapBitmap "rob/full.xbm"
                )
  }
  where
    wrapFgBg fgColor bgColor content= wrap ("^fg(" ++ fgColor ++ ")^bg(" ++ bgColor ++ ")") "^fg()^bg()" content
    wrapFg color content = wrap ("^fg(" ++ color ++ ")") "^fg()" content
    wrapBg color content = wrap ("^bg(" ++ color ++ ")") "^bg()" content
    wrapBitmap bitmap = "^p(5)^i(" ++ myBitmapsPath ++ bitmap ++ ")^p(5)"
 
-- Fading hook
myFadingHook = fadeInactiveLogHook fadeAmount
  where fadeAmount = 0.85
 
-- Define a combination of layouts
myLayoutHook = smartBorders $ (tiled ||| Mirror tiled ||| Full)
               -- The only window w/o borders
  where
    tiled = ResizableTall nmaster delta ratio []
    nmaster = 1
    delta = 3/100
    ratio = 1/2
 
-- Urgency hint configuration
myUrgencyHook = withUrgencyHook dzenUrgencyHook
    {
      args = [
         "-x", "0", "-y", "785", "-h", "15", "-w", "1280",
         "-ta", "r", "-expand", "l",
         "-fg", "" ++ myUrgencyHintFgColor ++ "",
         "-bg", "" ++ myUrgencyHintBgColor ++ "",
         "-fn", "" ++ myFont ++ ""
         ],
      duration = (7 `seconds`)
    }
 
-- Window rules
myManageHook = composeAll . concat $ [
  [isDialog --> doFloat],
  [className =? c --> doFloat | c <- myCFloats],
  [title =? t --> doFloat | t <- myTFloats],
  [resource =? r --> doFloat | r <- myRFloats],
  [resource =? i --> doIgnore | i <- myIgnores]
  ]
  where
    myCFloats = ["Xmessage"]
    myTFloats = ["Save As...", "Save File", "Options"]
    myRFloats = []
    myIgnores = ["XXkb"]