greshake / i3status-rust

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

Struggling with formatting syntax and the block docs #1155

Closed kgizdov closed 3 years ago

kgizdov commented 3 years ago

Hi,

I might be misunderstanding the variable formatting syntax. My config is below. The issue I'm having is that when I have "{ssid}" I get the actual SSID, which is too long, but when I put "{ssid^8}" I get exactly {ssid^8} not the SSID formatted to 8 characters long. I have a similar problem for temperatures. When I request "{min*deg}" I get exactly {max*deg} not, for example, 30Ā°C or anything. Another example is with network speed, "{speed_down;M*b}" does not produce the download speed formatted in Mbps. I've also failed to run the whole example on the memory block as the docs include an undefined value {mem_used}, which i3status-rs errors out on.

Am I using the formatting syntax incorrectly or in the wrong place or whatever? I have not been able to find any examples online anywhere for this.

OS: Arch Linux x64_86 pkgver: i3status-rust 0.14.7-1

# $ cat .config/i3status-rust/config.toml 
theme = "solarized-dark"
# [theme]
# name = "solarized-dark"

# icons = "awesome"  # "awesome5" is still broken
[icons]
name = "awesome"
[icons.overrides]
backlight_empty = " šŸŒ‘ "
backlight_partial1 = " šŸŒ˜ "
backlight_partial2 = " šŸŒ— "
backlight_partial3 = " šŸŒ– "
backlight_full = " šŸŒ• "

[[block]]
block = "pacman"
interval = 600
format = "{pacman} updates available"
format_singular = "{pacman} update available"
format_up_to_date = "system up to date"
critical_updates_regex = "(linux|linux-lts)"

[[block]]
block = "net"
device = "wlp58s0"
format = "{ssid^8} {signal_strength} {ip} {speed_down;M*b} {graph_down;M*b}"
interval = 5

[[block]]
block = "networkmanager"
on_click = "alacritty -e nmtui"
interface_name_exclude = ["br\\-[0-9a-f]{12}", "docker\\d+"]
interface_name_include = []
ap_format = "{ssid^8}"

[[block]]
block = "temperature"
collapsed = false
interval = 10
format = "{min*deg} min, {max*deg} max, {average*deg} avg"
# chip = "*-isa-*"
chip = "dell_smm-virtual-0"
inputs = ["CPU", "Ambient"]

[[block]]
block = "load"
format = "{1m}"
interval = 1

[[block]]
block = "memory"
# format_mem = "{mem_used}/{mem_total}({mem_used_percents})"
# format_swap = "{swap_used}/{swap_total}({swap_used_percents})"
display_type = "memory"
icons = true
clickable = true
interval = 5
warning_mem = 80
warning_swap = 80
critical_mem = 95
critical_swap = 95

[[block]]
block = "disk_space"
path = "/"
alias = "/"
info_type = "used"
unit = "GiB"
format = "{icon} {available}{unit} free"

[[block]]
block = "backlight"
device = "intel_backlight"

[[block]]
block = "battery"
# driver = "upower"
interval = 10
format = "{percentage}% {time}"

[[block]]
block = "time"
format = "%a %d/%m %R"
timezone = "Europe/London"
interval = 60
locale = "en_GB"
MaxVerevkin commented 3 years ago

i3status-rust 0.14.7-1

0.14.7 does not include the "advanced" formatting. I don't know when a new release is coming out, but since you use Arch Linux, you can try i3status-rust-git package from the AUR.

MaxVerevkin commented 3 years ago

backlight_empty = " šŸŒ‘ " backlight_partial1 = " šŸŒ˜ " backlight_partial2 = " šŸŒ— " backlight_partial3 = " šŸŒ– " backlight_full = " šŸŒ• "

The names for backlight's partial icons have been changed, need to add this in the NEWS.md file.

GladOSkar commented 3 years ago

You can now also use invert_icons = true on the backlight block instead :)

kgizdov commented 3 years ago

I see. OK, so the confusion is that the front page/Wiki docs are not tagged, then. Am I looking at the wrong place or something? (I will try the git version in the meantime. thx)

GladOSkar commented 3 years ago

No we don't really have versioned docs (except for the git revisions). Many/most users use the git version anyway, so we rarely thought about it. But at this point we could think about moving documentation to something like readthedocs or so, might also be better for discoverability

MaxVerevkin commented 3 years ago

You can select the git branch https://github.com/greshake/i3status-rust/tree/v0.14.7

MaxVerevkin commented 3 years ago

(except for the git revisions)

Isn't this enough? I mean I can just select the tag that I use and get all the docs. Am I missing something?

kgizdov commented 3 years ago

@MaxVerevkin haha, I know that, but I was talking about what @GladOSkar suggested. It's confusing in general to have your front facing docs apply only to the latest version - this means for the majority of time they are incorrect for everyone that does not explicitly require the version of docs they want. Sure, you can get the version you want, yes, but it is confusing by design.

kgizdov commented 3 years ago

so trying the i3status-rust-git package and a few observations:

MaxVerevkin commented 3 years ago

{graph_down;M*b}: still shows b and presume it uses bytes instead of the requested unit

Hmm. What is the expected behavior? (I don't get how do you what to customize the graph).

kgizdov commented 3 years ago

@MaxVerevkin it's true that the graph is scaled from 0 to 1, correct? So absolute unit doesn't matter for values really. However, I expect when the base unit is set to something, at least the icon/unit should reflect it. I guess this is for prettiness only, but it could also be used a sort of extra scaling if that is desirable by users. For example, if my graph is in bytes, it should start showing units immediately, but it it is in Mb, then it should only show activity if value > 0.1 Mb or some reasonable value depending on pixels. Something like that.

In any case, if the unit is updated, it would be enough for the moment.

kgizdov commented 3 years ago

hmm, I can't get the networkmanager block on_click to work either. I've tried:

[[block]]
block = "networkmanager"
# on_click = "alacritty -e nmtui"  # this does nothing
on_click = "nm-applet"  # this also does nothing
interface_name_exclude = ["br\\-[0-9a-f]{12}", "docker\\d+"]
interface_name_include = ["wlp58s0"]
ap_format = "{ssid^8}"
MaxVerevkin commented 3 years ago

it's true that the graph is scaled from 0 to 1, correct?

No. The graph scales from minimum speed to maximum speed within the last N seconds. So setting the unit for a graph doesn't make sense.

kgizdov commented 3 years ago

@MaxVerevkin yes, that is mathematically the same thing. Please try to understand what I've suggested.

MaxVerevkin commented 3 years ago

OK, so your idea is that if the unit/prefix for graph is set to, lets say Mb, the minimum should be 0.1Mb, and the maximum should be... something, right? If so, then I think it would be better to allow an explicit min and max values. You can propose a syntax for that.

kgizdov commented 3 years ago

Sure, whatever is easiest. I was more thinking of setting a minimum scaling factor, but it may turn out weird in the end anyway.