I3status-rust: Net format

Created on 19 Aug 2018  路  4Comments  路  Source: greshake/i3status-rust

Roboto Mono
Noto Sans

The net block has a few problems:

  • Takes too much space
  • Varies in width (particularly with prettier proportional fonts like Noto Sans Regular)

The point of a status bar is to get a quick, rough estimate of usage. This means 2-3 digits of precision, e.g.

4.20G
0.42G
42.0M
4.20M
0.42M
42.0K
4.20K
0.42K
4.20B
0.42B
0.04B
0.00B

The aforementioned representations do not (significantly) vary in width with proportional fonts.


I propose a format specification:

[[block]]
name = "net"
format = "{M.3}"

where:

  • M represents the limiting precision. (Anything below 0.01M is labeled 0.00M.)
  • .3 represents 3 digits of precision.

That is:

4.20G  <- Not really necessary...
0.42G  <- Not really necessary... 
42.0M
4.20M
0.42M
0.04M
0.00M
help wanted

Most helpful comment

Also, I think it's pretty pointless to show byte-level thoroughput in the net block -- it just leads to uninformative noise. Kilobytes should be the lowest unit.

All 4 comments

I'm a fan of adding some measure of control over precision as well, not only in the net block but in others as well. However, my recollection is that runtime string formatting is not built-in to Rust, and I wasn't able to come up with a good way to implement this when I investigated at the time.

(Note: your other issue seems to be that the net block takes up too much space; you can resolve this by turning on/off the various widgets, as described in blocks.md.)

Also, I think it's pretty pointless to show byte-level thoroughput in the net block -- it just leads to uninformative noise. Kilobytes should be the lowest unit.

OK i played around with implementing this a bit and i think this is a good implementation of what @SicariusNoctis suggested:

https://play.rust-lang.org/?gist=814e1d847d960a54690753c5c07fb56f [edited]

I really like this, it covers most of the formats i can think of.

Feel free to play around with it to see if it matches your idea.

@YodaEmbedding If you're still using i3status-rs, #704 should hopefully be what you wanted.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

l4l picture l4l  路  6Comments

concatime picture concatime  路  4Comments

jpeeler picture jpeeler  路  5Comments

marvin-steinke picture marvin-steinke  路  4Comments

Nukesor picture Nukesor  路  5Comments