Reputation: 92
My dotfiles are 99% similar between computers but there are minor tweaks that I keep for various minor settings. My plan was to discriminate using an if statement based on hostname. something that would look as follows in a shell config like bashrc or zshrc
if [ $(hostname) == 'host1' ]; then
# things to do differently on host1.
elif [ $(hostname) == 'host2' ]; then
# things to do differently on host2.
fi
I suspect that xmobar is simply a config file that is parsed with no real haskell in it. Any thoughts on how to get something similar to what I have with a shell in xmobar?
Mainly I am wanting to modify the widths and network interfaces in xmobar something like
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>"
}
I realize my syntax is wishful and likely wrong, I love xmonad but have not learned haskell syntax yet.
Upvotes: 0
Views: 998
Reputation: 48766
Since xmonad.hs
is a haskell file, you can use the package hostname, to find it's name:
In ghci:
λ> import Network.HostName
λ> getHostName
Loading package hostname-1.0 ... linking ... done.
"hostname1"
It seems you want to have different xmobar
settings for your host. One way to achieve that would be to write a function that will create a new .xmobarrc
file for your given host. It's type definition will look something like this:
createXmobarrc :: String -> IO ()
createXmobarrc hostname = undefined -- Write your logic
You can then call this method in the appropriate place in your xmonad.hs
file using the following pattern:
main = do
hostname <- getHostName
createXmobarrc hostname -- produce appropriate .xmobarrc file for a given host
-- other xmonad stuff follows here
Upvotes: 1