Difference between revisions of "Xmonad/Config archive/skorpan's xmonad.hs"
< Xmonad | Config archive
Jump to navigation
Jump to search
(Updating.) |
|||
(4 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
+ | <haskell>import System.Exit |
||
− | -- |
||
− | -- ~/.xmonad/xmonad.hs |
||
− | -- |
||
− | |||
− | -- import the necessary libraries |
||
− | |||
import XMonad |
import XMonad |
||
− | import XMonad. |
+ | import XMonad.Hooks.DynamicLog |
− | import XMonad. |
+ | import XMonad.Hooks.ManageDocks |
− | import XMonad. |
+ | import XMonad.Layout.NoBorders |
− | import XMonad. |
+ | import XMonad.Prompt (defaultXPConfig) |
− | import XMonad. |
+ | import XMonad.Prompt.Shell (shellPrompt) |
− | import XMonad. |
+ | import XMonad.Util.EZConfig |
− | import XMonad.Actions.SinkAll |
||
− | import XMonad.Hooks.DynamicLog ( PP(..), dynamicLogWithPP, dzenColor, wrap, defaultPP ) |
||
− | import XMonad.Hooks.UrgencyHook |
||
− | import XMonad.Layout.Grid |
||
− | import XMonad.Layout.Maximize |
||
− | import XMonad.Layout.NoBorders ( noBorders, smartBorders ) |
||
− | import XMonad.Layout.Tabbed |
||
− | import XMonad.Layout.ToggleLayouts |
||
import XMonad.Util.Run |
import XMonad.Util.Run |
||
import qualified XMonad.StackSet as W |
import qualified XMonad.StackSet as W |
||
− | import qualified |
+ | import qualified Data.Map as M |
− | import qualified Data.Map as M |
||
− | import Data.Bits ((.|.)) |
||
− | import Data.Ratio |
||
− | import Graphics.X11 |
||
− | import System.IO |
||
− | dmenuExec = "exe=`dmenu_path | dmenu -b -fn '-*-terminus-*-r-normal-*-*-120-*-*-*-*-iso8859-*' -nb '#000000' -nf '#FFFFFF' -sb '#333333'` && eval \"exec $exe\"" |
||
− | myIconsDir = "/home/deniz/usr/share/dzen2/icons" |
||
− | myStatusBar = "dzen2 -bg '#222222' -fg '#777777' -h 16 -w 640 -sa c -e '' -fn '-*-terminus-*-r-normal-*-*-120-*-*-*-*-iso8859-*' -ta l" |
||
− | |||
− | main = do din <- spawnPipe myStatusBar |
||
− | xmonad $ defaultConfig |
||
− | { borderWidth = 2 |
||
− | , normalBorderColor = "#555555" |
||
− | , focusedBorderColor = "#dddddd" |
||
− | , workspaces = |
||
− | ["1:main", "2:web", "3:dev"] ++ |
||
− | map show [4..7] ++ ["8:warez","9:music"] |
||
− | , terminal = "urxvt" |
||
− | , modMask = mod4Mask |
||
− | , defaultGaps = [(16,0,0,0)] |
||
− | , manageHook = manageHook defaultConfig <+> myManageHook |
||
− | , logHook = dynamicLogWithPP $ myPP din |
||
− | , layoutHook = toggleLayouts (noBorders Full) $ |
||
− | smartBorders $ |
||
− | tiled ||| |
||
− | Mirror tiled |
||
− | ||| Full |
||
− | ||| Grid |
||
− | ||| tabbed shrinkText defaultTConf |
||
− | ||| maximize (Tall 1 (3%100) (1%2)) |
||
− | , keys = \c -> myKeys c `M.union` keys defaultConfig c |
||
− | , mouseBindings = \c -> myMouse c `M.union` mouseBindings defaultConfig c |
||
− | } |
||
− | where |
||
− | tiled = Tall nmaster delta ratio |
||
− | nmaster = 1 |
||
− | ratio = 50%100 |
||
− | delta = 5%100 |
||
+ | myKeys c = mkKeymap c $ |
||
− | -- application control |
||
+ | [ ("M-<Return>", spawn $ XMonad.terminal c) |
||
− | -- |
||
+ | , ("M-<Space>", sendMessage NextLayout) |
||
− | myManageHook :: ManageHook |
||
+ | , ("M-<Tab>", windows W.focusDown) |
||
− | myManageHook = composeAll . concat $ |
||
+ | , ("M-S-<Return>", windows W.swapMaster) |
||
− | [ [ className =? c --> doFloat | c <- myFloats] |
||
− | + | , ("M-S-c", kill) |
|
− | + | , ("M-S-q", io (exitWith ExitSuccess)) |
|
− | + | , ("M-b", sendMessage ToggleStruts) |
|
+ | , ("M-h", sendMessage Shrink) |
||
+ | , ("M-l", sendMessage Expand) |
||
+ | , ("M-n", refresh) |
||
+ | , ("M-q", broadcastMessage ReleaseResources >> restart "xmonad" True) |
||
+ | , ("M-t", withFocused $ windows . W.sink) |
||
+ | , ("M-x", shellPrompt defaultXPConfig)] |
||
+ | ++ |
||
+ | [(m ++ k, windows $ f w) |
||
+ | | (w, k) <- zip (XMonad.workspaces c) (map show [1..9]) |
||
+ | , (m, f) <- [("M-",W.greedyView), ("M-S-",W.shift)]] |
||
+ | |||
+ | |||
+ | myMouseBindings (XConfig {XMonad.modMask = modMask}) = M.fromList $ |
||
+ | [ ((modMask, button1), (\w -> focus w >> mouseMoveWindow w)) |
||
+ | , ((modMask, button2), (\w -> focus w >> windows W.swapMaster)) |
||
+ | , ((modMask, button3), (\w -> focus w >> mouseResizeWindow w)) |
||
] |
] |
||
− | where |
||
− | myIgnores = [] |
||
− | myFloats = ["feh", |
||
− | "GIMP", |
||
− | "gimp"] |
||
− | myOtherFloats = ["Bon Echo Preferences", |
||
− | "Mail/News Preferences", |
||
− | "Bon Echo - Restore Previous Session", |
||
− | "MPlayer"] |
||
− | -- modify/add default key binds |
||
− | -- |
||
− | myKeys conf@(XConfig {modMask = modm}) = M.fromList $ |
||
− | [ ((modm, xK_p ), spawn dmenuExec) |
||
− | , ((modm, xK_x ), sendMessage ToggleLayout) |
||
− | , ((modm, xK_z ), toggleWS) |
||
− | , ((modm, xK_Left ), windows W.focusUp) |
||
− | , ((modm, xK_Right ), windows W.focusDown) |
||
− | , ((modm, xK_Up ), windows W.focusUp) |
||
− | , ((modm, xK_Down ), windows W.focusDown) |
||
− | , ((modm, xK_Return ), spawn $ XMonad.terminal conf) |
||
− | , ((modm .|. shiftMask, xK_Tab ), rotSlavesUp) |
||
− | , ((modm .|. shiftMask, xK_Right ), rotView True) |
||
− | , ((modm .|. shiftMask, xK_Left ), rotView False) |
||
− | ] |
||
− | |||
− | -- modify/add default mouse binds |
||
− | -- |
||
− | myMouse (XConfig {modMask = modm}) = M.fromList $ |
||
− | [ ((modm, button3), (\w -> focus w >> Flex.mouseResizeWindow w)) |
||
− | , ((modm, button4), (\_ -> rotView True)) |
||
− | , ((modm, button5), (\_ -> rotView False)) |
||
− | ] |
||
+ | myLayoutHook = smartBorders $ avoidStruts $ tiled ||| Mirror tiled ||| Full |
||
− | -- dynamiclog pretty printer for dzen |
||
+ | where |
||
− | -- ironic that this is "pretty printer" with such fugly code. |
||
+ | tiled = Tall nmaster delta ratio |
||
− | myPP h = defaultPP |
||
+ | nmaster = 1 |
||
− | { ppCurrent = wrap "^fg(#ffffff)^bg(#888888)^p(3)" "^p(2)^fg()^bg()" . \wsId -> |
||
+ | ratio = 1/2 |
||
− | if (':' `elem` wsId) then |
||
− | + | delta = 4/100 |
|
+ | |||
− | else wsId |
||
+ | |||
− | , ppVisible = wrap "^bg(grey30)^fg(grey75)^p(2)" "^p(2)^fg()^bg()" |
||
+ | myManageHook = composeAll |
||
− | , ppHidden = wrap "^fg(#ffffff)^bg()^p(2)" "^p(3)^fg()^bg()" . \wsId -> |
||
− | + | [ floatC "MPlayer" |
|
− | + | , floatC "Gimp" |
|
− | + | , moveToC "Conkeror" "2" |
|
− | + | ] |
|
+ | where moveToC c w = className =? c --> doF (W.shift w) |
||
− | if (':' `elem` wsId) then |
||
− | + | moveToT t w = title =? t --> doF (W.shift w) |
|
− | + | floatC c = className =? c --> doFloat |
|
+ | |||
− | , ppSep = " ^fg(#ffffff)^r(2x2)^p(2)^fg() " |
||
+ | |||
− | , ppWsSep = " " |
||
+ | myLogHook xmobar = dynamicLogWithPP $ defaultPP { |
||
− | , ppLayout = (\x -> case x of |
||
− | + | ppOutput = hPutStrLn xmobar |
|
− | + | , ppTitle = xmobarColor "white" "" . shorten 110 |
|
− | + | , ppCurrent = xmobarColor "white" "black" . pad |
|
− | + | , ppHidden = pad |
|
− | + | , ppHiddenNoWindows = \w -> xmobarColor "#444" "" (" " ++ w ++ " ") |
|
− | + | , ppSep = xmobarColor "#555" "" " / " |
|
− | + | , ppWsSep = "" |
|
− | + | , ppLayout = \x -> case x of |
|
− | " |
+ | "Tall" -> "T" |
− | + | "Mirror Tall" -> "M" |
|
− | + | "Full" -> "F" |
|
− | + | _ -> "?" |
|
− | + | } |
|
+ | |||
− | , ppTitle = dzenColor "white" "" |
||
+ | |||
− | , ppOutput = hPutStrLn h |
||
+ | main = do xmobar <- spawnPipe "xmobar" |
||
− | } |
||
+ | xmonad $ defaultConfig { |
||
+ | terminal = "urxvtc", |
||
+ | focusFollowsMouse = True, |
||
+ | borderWidth = 2, |
||
+ | modMask = mod4Mask, |
||
+ | numlockMask = 0, |
||
+ | workspaces = [ show x | x <- [1..9] ], |
||
+ | normalBorderColor = "#444", |
||
+ | focusedBorderColor = "#f00", |
||
+ | keys = myKeys, |
||
+ | mouseBindings = myMouseBindings, |
||
+ | layoutHook = myLayoutHook, |
||
+ | manageHook = myManageHook, |
||
+ | logHook = myLogHook xmobar |
||
+ | } |
||
+ | </haskell> |
Latest revision as of 17:28, 25 January 2009
import System.Exit
import XMonad
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.ManageDocks
import XMonad.Layout.NoBorders
import XMonad.Prompt (defaultXPConfig)
import XMonad.Prompt.Shell (shellPrompt)
import XMonad.Util.EZConfig
import XMonad.Util.Run
import qualified XMonad.StackSet as W
import qualified Data.Map as M
myKeys c = mkKeymap c $
[ ("M-<Return>", spawn $ XMonad.terminal c)
, ("M-<Space>", sendMessage NextLayout)
, ("M-<Tab>", windows W.focusDown)
, ("M-S-<Return>", windows W.swapMaster)
, ("M-S-c", kill)
, ("M-S-q", io (exitWith ExitSuccess))
, ("M-b", sendMessage ToggleStruts)
, ("M-h", sendMessage Shrink)
, ("M-l", sendMessage Expand)
, ("M-n", refresh)
, ("M-q", broadcastMessage ReleaseResources >> restart "xmonad" True)
, ("M-t", withFocused $ windows . W.sink)
, ("M-x", shellPrompt defaultXPConfig)]
++
[(m ++ k, windows $ f w)
| (w, k) <- zip (XMonad.workspaces c) (map show [1..9])
, (m, f) <- [("M-",W.greedyView), ("M-S-",W.shift)]]
myMouseBindings (XConfig {XMonad.modMask = modMask}) = M.fromList $
[ ((modMask, button1), (\w -> focus w >> mouseMoveWindow w))
, ((modMask, button2), (\w -> focus w >> windows W.swapMaster))
, ((modMask, button3), (\w -> focus w >> mouseResizeWindow w))
]
myLayoutHook = smartBorders $ avoidStruts $ tiled ||| Mirror tiled ||| Full
where
tiled = Tall nmaster delta ratio
nmaster = 1
ratio = 1/2
delta = 4/100
myManageHook = composeAll
[ floatC "MPlayer"
, floatC "Gimp"
, moveToC "Conkeror" "2"
]
where moveToC c w = className =? c --> doF (W.shift w)
moveToT t w = title =? t --> doF (W.shift w)
floatC c = className =? c --> doFloat
myLogHook xmobar = dynamicLogWithPP $ defaultPP {
ppOutput = hPutStrLn xmobar
, ppTitle = xmobarColor "white" "" . shorten 110
, ppCurrent = xmobarColor "white" "black" . pad
, ppHidden = pad
, ppHiddenNoWindows = \w -> xmobarColor "#444" "" (" " ++ w ++ " ")
, ppSep = xmobarColor "#555" "" " / "
, ppWsSep = ""
, ppLayout = \x -> case x of
"Tall" -> "T"
"Mirror Tall" -> "M"
"Full" -> "F"
_ -> "?"
}
main = do xmobar <- spawnPipe "xmobar"
xmonad $ defaultConfig {
terminal = "urxvtc",
focusFollowsMouse = True,
borderWidth = 2,
modMask = mod4Mask,
numlockMask = 0,
workspaces = [ show x | x <- [1..9] ],
normalBorderColor = "#444",
focusedBorderColor = "#f00",
keys = myKeys,
mouseBindings = myMouseBindings,
layoutHook = myLayoutHook,
manageHook = myManageHook,
logHook = myLogHook xmobar
}