i3status-rust icon indicating copy to clipboard operation
i3status-rust copied to clipboard

formatting(eng): add `range` parameter

Open MaxVerevkin opened this issue 1 year ago • 2 comments

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

  • [ ] Add examles to the blocks that would benefit from it.
  • [x] Support half-ranges. Like 10...

MaxVerevkin avatar Apr 13 '24 14:04 MaxVerevkin

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

bim9262 avatar Apr 13 '24 15:04 bim9262

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.

ismay avatar Apr 18 '24 12:04 ismay

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

bim9262 avatar Apr 22 '24 16:04 bim9262

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.

MaxVerevkin avatar Apr 23 '24 08:04 MaxVerevkin

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

bim9262 avatar Apr 28 '24 15:04 bim9262