greshake / i3status-rust

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

Vertical bars for percentages as progression #1886

Closed Atreyagaurav closed 1 year ago

Atreyagaurav commented 1 year ago

How about we have this sequence:

printf "%b " "\u2581" "\u2582" "\u2583" "\u2584" "\u2585" "\u2586" "\u2587\n"

▁ ▂ ▃ ▄ ▅ ▆ ▇

It doesn't need to have multiple character, just a progression sequence that'll emulate the vertical bar like thing and it's unicode and we can have this added near the symbols that give percentage. We can add *_bar variety for them and use these that people can use instead of percentages.

diff --git a/files/icons/awesome6.toml b/files/icons/awesome6.toml
index 807fc122..2e9f9f1d 100644
--- a/files/icons/awesome6.toml
+++ b/files/icons/awesome6.toml
@@ -70,6 +70,15 @@ toggle_on = "\uf205"
 unknown = "\uf128"
 update = "\uf062"
 uptime = "\uf2f2"
+vertical_bar = [
+     "\u2581",
+     "\u2582",
+     "\u2583",
+     "\u2584",
+     "\u2585",
+     "\u2586",
+     "\u2587"
+]
 volume = [
     "\uf026",
     "\uf027",

I can make the pull request if you guys think it's a good idea. I think it is, as it allows us to have sort of progression symbol for icon themes that don't have progressions.

For example here image it has net_wireless with bar on the side.

Here is the horizontal one, but I think vertical looks better.

printf "%b " "\u258F" "\u258E" "\u258D" "\u258C" "\u258B" "\u258A" "\u2589\n"

Here are the descriptions of the characters: https://en.wikipedia.org/wiki/Block_Elements

MaxVerevkin commented 1 year ago

I suppose it would be useful if icons overrides could "link" to other icons, right?

MaxVerevkin commented 1 year ago

Or do you mean that we can have net_wireless and net_wireless_bar?

Atreyagaurav commented 1 year ago

The second one. A config use_bar_on_percentage could also work globally. But the *_bar would allow finer control.

Atreyagaurav commented 1 year ago

Not net_wireless_bar. but rather vertical_bar in the icon theme that can be used to provide the format string variables, like for net block format = " $icon {$signal_strength $ssid} " could be format = " $icon {$signal_strength_bar $ssid} " And we'll use the vertical bar uncodes to provide them Value::icon(api.get_icon_in_progression("vertical_bar", percent / 100.0)?)); like this.

MaxVerevkin commented 1 year ago

This can be implemented as a formatter. We already have "bar" but it renders horizontally : https://docs.rs/i3status-rs/latest/i3status_rs/formatting/index.html#bar---display-numbers-as-progress-bars

An option can be added to render vertically.

Atreyagaurav commented 1 year ago

I'll work on this after the kdeconnect network issue is closed. I haven't used any bar options based on the value, but that definitely seems like a better option if we can use values from the variables, than more variables for each value.