Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1730381
  • 博文数量: 410
  • 博客积分: 9563
  • 博客等级: 中将
  • 技术积分: 4517
  • 用 户 组: 普通用户
  • 注册时间: 2010-07-03 19:59
个人简介

文章分类

全部博文(410)

文章存档

2017年(6)

2016年(1)

2015年(3)

2014年(4)

2013年(32)

2012年(45)

2011年(179)

2010年(140)

分类: LINUX

2011-03-14 20:59:46


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
阅读(982) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~