Skip to content

Conversation

@zheltikov
Copy link
Contributor

@zheltikov zheltikov commented Jan 7, 2026

Resolves #1555 .

Changelog

  • Add new ValueInner::Numbers variant for collections of values. Supports two formatting modes:

    • EngFormatter: (default) just renders the last value of the set like a regular Value::Number.
    • BarFormatter: if vertical, renders a barchart with the last width values from the set; if horizontal, renders the last value as a "meter" bar.
  • Refactor EngFormatter and BarFormatter to implement formatting of new Value::Numbers variant. Add unit tests with examples for BarFormatter.

  • Refactor cpu and net blocks to use the new BarFormatter functionality.

Open questions

  1. The current approach is not too flexible: it does not allow to "smartly" detect the width or max_value of the bar charts. This has to be manually be set in the user's config.toml file.
    1.1. max_value: can be automatically detected in the BarFormatter on the fly, while rendering the barchart. But then, the manual max_value user formatting argument has to be made optional in some cases. When?
    1.2. width: should be exposed somehow to the blocks by the formatter, and vice-versa? In case of the net block, we should only accumulate as much data as we would render. In case of the cpu block, it has to be enforced the other way around: number of cores from the block to the formatter.
    1.3. the examples and solutions proposed above would create some confusion both code-wise (block-logic and formatting logic are now aware of each-other and coupled) and usage-wise (the user's formatting arguments in their config file should be followed or ignored in some cases).

@MaxVerevkin , @bim9262 , thoughts on the current implementation and the open questions?

…e values.

- Refactor BarFormatter code for handling single Value::Number.
- BarFormatter now prints Value::Numbers as a windowed chart if vertical; otherwise, prints the last value in the series as a single horizontal bar.
… appropriate bar, this is noticeable on almost-zero values.
@bim9262
Copy link
Collaborator

bim9262 commented Jan 11, 2026

I haven't had a chance to fully review this, but I worked on this last year too. Maybe it can help 🤷‍♂️

https://github.com/greshake/i3status-rust/compare/master...bim9262:i3status-rust:bar_graph?expand=1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

v0.30: reimplement "Net graph formatting"

2 participants