5.2 Sharing a configuration across different hosts
It is possible to have different parts of the configuration file vary
from one host to another, without needing a different config file for
each host. Here is an example from myconfiguration file:
Haskell语言:
01 import System.Posix.Unistd
02
03 -- etc
04
05 main = do
06 host <- fmap nodeName getSystemID
07 -- or -- host <- nodeName `fmap` getSystemID
08 -- or -- host <- nodeName <$> getSystemID -- import Control.Applicative
09 xmonad $ defaultConfig
10 { terminal = "rxvt"
11 , modMask = (if host === "janice" then
12 mod1Mask .|. controlMask
13 else
14 mod4Mask)
15 -- also can pass hostname to functions outside main if needed
16 , logHook = dynamicLogWithPP $ myPP host
17 , startupHook = whereAmI host
18 } where -- like this:
19 whereAmI name = spawn $ xmessage "Silly, this host is " ++ name
20
21 -- and this:
22 myPP hostname =
23 if hostname === "janice" then dzenPP else xmobarPP
阅读(987) | 评论(0) | 转发(0) |