Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>For the first question:</strong></p> <p>Thomas' answer seems like it would work, but it doesn't. The xmobarrc file syntax looks like Haskell, but it's actually very restrictive about how it's formatted, and it doesn't support any of the Haskell syntax except for what's already in the file.</p> <p>That said, the obvious answer is to just color each of them individually. The result is a template line that's a bit longer and less pretty than it probably should be, and it would be more work to change it later on, but honestly, there are only four <code>|</code> characters, so it isn't that bad.</p> <p>A nicer looking solution is to set <code>fgColor = "#ffffff"</code>, and then add <code>"--low","#8080A1"</code> to the options list of each of your commands, and wrap <code>%StdinReader%</code> and <code>%date%</code> in <code>&lt;fc=#8080A1&gt;&lt;/fc&gt;</code>. Basically, set the default color to the <code>|</code> color, and explicitly color everything else. This way, you avoid writing all those <code>fc</code> tags, because that color is implicit. I wouldn't recommend doing it this way though, as it decreases the clarity of the file somewhat.</p> <p>Now, there actually is a much better way to do this, that fixes this problem and all related problems entirely: write it in real Haskell. What you would do is, write a Haskell program that ultimately builds and formats the proper xmobarrc, and then prints it to a file. I personally think this is a good option for any annoying config file, but xmobarrc is an especially good candidate for it, because its syntax is so close to Haskell's. More specifically, the syntax xmobarrc does use is entirely the syntax Haskell uses to describe literal data, which means all we have to do is build a <code>Config</code> object and run its default <code>show</code>, and all the rest of the work is done for us, other than a few tiny differences. Actually, here, I'll write this up really quick for you ... <a href="https://gist.github.com/4522828" rel="nofollow">here</a>. Now, if you import that, and define a Main file like so:</p> <pre><code>module Main (main) where import XMobarHs main = export $ config { lowerOnStart = False , font = "xft:Terminus-12" , bgColor = "#000000" , fgColor = "#8080A1" , position = Top , commands = [ Run $ Network "eth0" ["-L","0","-H","32","--normal","#429942","--high","#A36666"] 10 , Run $ Cpu ["-L","3","-H","50","--normal","green","--high","red"] 10 , Run $ Memory ["-t","Mem: &lt;usedratio&gt;%"] 10 , Run $ Date "/%a/ %_d.%m.%Y / %H:%M" "date" 10 , Run $ Com "sh" ["~/bin/weather.sh"] "weather" 60 , Run $ StdinReader ] , sepChar = "%" , alignSep = "}{" , template = " %StdinReader% }{ W:&lt;fc=#fce94f&gt;%weather%&lt;/fc&gt; | %cpu% | %memory% | %eth0% | %date%" } </code></pre> <p>It's almost exactly the same. But it doesn't have to be, because it's literally Haskell now, so you're actually allowed to use Thomas' idea, or go much, much further than that, to whatever degree you feel is best. The only drawback is, every time you edit the file, you have to compile and run it again, to get an updated xmobarrc.</p> <p><strong>For the second question:</strong></p> <p>In a command's option list, add <code>"-w","3"</code>, replacing 3 with the size (in number of characters) that you want the command's fields to be fixed at. This will truncate a field if it goes over that size, and pad the field with spaces if it goes under. If you want to pad with 0's (or some other character) instead of spaces, add <code>"-c","0"</code> as well (or <code>"-c","n"</code>, replacing n with the character you want to pad with).</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload