greshake / i3status-rust

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

formatting(eng): add `range` parameter #2043

Closed MaxVerevkin closed 5 months ago

MaxVerevkin commented 5 months ago

Closes #1957

Example

Show the cpu block only if utilization is above 10%:

[[block]]
block = "cpu"
format = " $icon $utilization.eng(range:10..) |"

Unresolved Questions

Support disjoint ranges? Would it be useful? How? Maybe by allowing multiple range arguments.

Todo

bim9262 commented 5 months ago

For the partial ranges we can check to see if start/stop are empty strings and if so use f64's min/max values

ismay commented 5 months ago

Support disjoint ranges? Would it be useful? How? Maybe by allowing multiple range arguments.

My 2 cents would be that the usecase hasn't come up yet, as far as I can tell. Could be tackled if and when it does.

bim9262 commented 5 months ago

I think range(..25), range(75..) or range(..25,75..) would be ok. I think I prefer the two range parameters as it's easier to read. I also agree that could be added in another PR

MaxVerevkin commented 5 months ago

Show the block only if less than 10GB is available:

[[block]]
block = "disk_space"
format = " $free.eng(range:..10e9) |"

Uhh. Do we want to support prefixes in ranges? Like range:..10Gi and range:..10M.

bim9262 commented 5 months ago

Show the block only if less than 10GB is available:

[[block]]
block = "disk_space"
format = " $free.eng(range:..10e9) |"

Uhh. Do we want to support prefixes in ranges? Like range:..10Gi and range:..10M.

That seems intuitive, could be done in another PR though as it wouldn't be breaking change