我的点文件是99%相似的计算机之间,但有一些小的调整,我保留为各种次要的设置。我的计划是使用基于主机名的if语句进行区分。在shell配置中如下所示的东西,如bashrc或zshrc
if [ $(hostname) == 'host1' ]; then
# things to do differently on host1.
elif [ $(hostname) == 'host2' ]; then
# things to do differently on host2.
fi我怀疑xmobar只是一个被解析的配置文件,其中没有真正的haskell。对于如何获得类似于xmobar中的shell的东西,有什么想法吗?
我主要想修改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语法。
发布于 2014-05-22 04:42:00
由于xmonad.hs是haskell文件,所以可以使用包主机名查找它的名称:
在ghci:
λ> import Network.HostName
λ> getHostName
Loading package hostname-1.0 ... linking ... done.
"hostname1"您似乎希望为主机设置不同的xmobar设置。实现这一目标的一种方法是编写一个函数,该函数将为给定主机创建一个新的.xmobarrc文件。它的类型定义如下所示:
createXmobarrc :: String -> IO ()
createXmobarrc hostname = undefined -- Write your logic然后,可以使用以下模式在xmonad.hs文件的适当位置调用此方法:
main = do
hostname <- getHostName
createXmobarrc hostname -- produce appropriate .xmobarrc file for a given host
-- other xmonad stuff follows herehttps://stackoverflow.com/questions/23797702
复制相似问题