greshake / i3status-rust

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

feature_request(memory): treat `swap_used` zero value as `false` in conditions #1957

Closed UnkwUsr closed 2 months ago

UnkwUsr commented 9 months ago

Problem

Formatting doc says (if I understand it correctly) that we can write conditions like Percentage: $percentage|nothing here.

I would like to make memory block hidden when swap_used is zero, so I'm trying format = "$swap_used|nothing" but it shows "0B".

Possible solutions

  1. Maybe hack swap_used so zero value will fallback to category "missing placeholder"?
  2. Add formatter option for type Number, like ignore_zero or ignore_threshold. This is more general approach.
MaxVerevkin commented 9 months ago

Add formatter option for type Number, like ignore_zero or ignore_threshold. This is more general approach.

I like this. Or even add an option to .eng formatter. Maybe .eng(allow:1..100) or something.

ismay commented 3 months ago

Maybe .eng(allow:1..100) or something.

So the above came up as a potential solution for #1768 as well. Usecase being: showing disk usage, memory usage and other blocks conditionally. Should we rephrase this issue a little broader to encompass that? Or maybe create a new issue that specifically mentions the creation of an (allow:1..100) formatter?