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 block #55

Closed etrombly closed 7 years ago

etrombly commented 7 years ago

I started working on a net block (just rx and tx). Before I get much farther was wondering if people wanted it configurable to show a specific output, like MBps, or have it scale with a label that changes. I have the output labeled "⬆" and "⬇", is that something people would want configurable as well, or would those defaults be ok?

Also related, I think it would be nice to have a graph output similar to i3pystatus.

greshake commented 7 years ago

Hey, welcome and thanks for your help! You can find examples of how to implement different units elegantly in the disk usage block. Units should be configurable (Kbps, Mbps, MB/s, etc.). You can use icons for the up/down label, and define them as text UP and DOWN for when the user selects the text icons. Could you elaborate on the graph thing? I don't know how we can display a proper graph with text only...

etrombly commented 7 years ago

I have the units autoscale currently, I can make it configurable. I had the arrows hard coded, I'll change it to a definition like you recommended.

Current graph trait is in https://github.com/etrombly/i3status-rust/blob/net/src/blocks/net.rs with an implementation for Vec\<u64>. Need to add fields for defined min and max, for example cpu usage would be 0 min and 100 max. Seems to be working well though, so it should probably be somewhere that's available to all blocks, not just in the net block. I basically just ported the make_graph function from i3pystatus.

Currently I just show rx and tx speed, not sure if I should add IP address, wifi ssid, etc or just have those be different blocks.

greshake commented 7 years ago

Okay, I like the idea of using the ["_","▁","▂","▃","▄","▅","▆","▇","█"] symbols. I thought maybe I had overlooked a feature of i3bar making this easier. Will have to try before I judge how well this does though :+1:

greshake commented 7 years ago

If this works well, please make the graph trait thing a separate PR and add it to utils or make it a separate widget (my recommendation), e.g. add a GraphWidget analogous to the Text and ButtonWidgets. Then you also have greater control over caching/rendering etc.

etrombly commented 7 years ago

I'll have to play around with it a little, I guess it depends on if you're going to typically want to display a graph alongside text, or standalone. I'll try both.

How good it looks is a little dependent on font. Font Awesome seems to have some character size issues, so the output jumps around a little. For now I've settled on Bitstream Vera Sans from the powerline patched nerd fonts (on Arch).

greshake commented 7 years ago

You can output more than one widget per view() of your block, so you can have text, buttons and a graph or whatever. If you're using a special/different iconic font, please document and/or add another icon set to icons.rs, specialising in the icons of that font (may have different unicode codes).

etrombly commented 7 years ago

ok, using the same icons for now. I'll document if anything changes. The issue I was having with FontAwesome is it doesn't seem totally fixed-width, so the output jumps around a little bit. Also Bitstream renders the bar characters used in the graph a little nicer.

I'll split my updates into two pulls once I get everything working.

greshake commented 7 years ago

Merged in #63