greshake / i3status-rust

Very resourcefriendly and feature-rich replacement for i3status, written in pure Rust
GNU General Public License v3.0
2.88k stars 475 forks source link

Net format #240

Closed YodaEmbedding closed 4 years ago

YodaEmbedding commented 6 years ago

Roboto Mono Noto Sans

The net block has a few problems:

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:

That is:

4.20G  <- Not really necessary...
0.42G  <- Not really necessary... 
42.0M
4.20M
0.42M
0.04M
0.00M
atheriel commented 6 years ago

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.)

atheriel commented 6 years ago

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.

GladOSkar commented 6 years ago

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.

ammgws commented 4 years ago

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