【发布时间】:2014-05-22 13:02:01
【问题描述】:
我的点文件在计算机之间有 99% 的相似性,但我保留了一些小的调整 对于各种次要设置。 我的计划是使用基于主机名的 if 语句进行区分。 在 bashrc 或 zshrc 等 shell 配置中看起来如下所示的内容
if [ $(hostname) == 'host1' ]; then
# things to do differently on host1.
elif [ $(hostname) == 'host2' ]; then
# things to do differently on host2.
fi
我怀疑 xmobar 只是一个配置文件,其中没有真正的 haskell 进行解析。 关于如何获得类似于我在 xmobar 中的外壳的任何想法?
主要是我想修改 xmobar 中的宽度和网络接口,比如
Config {
if hostname == "host1"
then
font = "xft:Fixed-9",
position = Static { xpos = 0, ypos = 0, width = 1280, height = 16 },
else if hostname == "host2"
then
font = "xft:Fixed-12",
position = Static { xpos = 1920, ypos = 0, width = 1800, height = 16 },
lowerOnStart = True,
commands = [
-- if here as well to switch between eth0 and wls3
Run Network "wls3" ["-t","Net: <rx>, <tx>","-H","200","-L","10","-h","#cc9393","-l","#709080","-n","#705050"] 10,
Run Date "%a %b %_d %l:%M" "date" 10,
Run Battery ["-t", "Bat: <left>%","-L","10","-H","11","-l","#CC9393","-h","#709080"] 10,
Run StdinReader
],
sepChar = "%",
alignSep = "}{",
template = "%StdinReader% }{ %multicpu% | %memory% | %Vol% | %wls3% | %battery% | <fc=#709080>%date%</fc>"
}
我意识到我的语法是一厢情愿并且可能是错误的,我喜欢 xmonad 但还没有学习过 haskell 语法。
【问题讨论】:
-
xmonad的配置文件只是一段Haskell代码,所以你可以通过
Network包中的getEnv "HOST"或getHostName获取主机名。但是我不认为这就是你想要的答案,所以你能解释一下你在 xmonad 的配置文件中真正想要完成的事情吗? -
我刚刚使用 xmobar.hs 文件中的 sn-p 进行了更新。我想“.hs”结尾应该让我知道它是代码而不是简单的配置,而是 haskell 语法对我来说很陌生。
-
@bertabus 我不确定
xmobar的最新版本,但旧版本通常会解析.xmobarrc文件。因此,您无法在该文件中输入 cmets。如果现在仍然如此,我认为您不能在该文件中使用if else表达式。如果最近的版本不是这种情况,我会很高兴,但我不确定。