i3status-rust
i3status-rust copied to clipboard
Battery: add `not_charging_format` config option
Battery config
[[block]]
block = "battery"
format = "{percentage:2}"
device = "BAT0"
allow_missing = true
i3status-rust version: 0.21.2
Linux kernel version: 5.15.17

This is all I see

Using upower also has the same behaviour.
Let me know if there anything I can do to debug this issue.
Can you check whether it works on the async branch (you'll need to adapt your format a little)?
@MaxVerevkin
Im getting the following compile error:
error: linking with `cc` failed: exit status: 1
...
= note: /usr/bin/ld: cannot find -lnotmuch
/usr/bin/ld: cannot find -lsensors
collect2: error: ld returned 1 exit status
Did the dependencies change?
I am using rust 1.57 and cargo 0.58.0
If you use debian-based distro, run sudo apt-get install libsensors-dev libnotmuch-dev.
Did the dependencies change?
libsensors-dev is a new dependency, libnotmuch-dev will soon be optional.
Can you check whether it works on the
asyncbranch (you'll need to adapt your format a little)?
Using the following config and the async branch
[[block]]
block = "battery"
The same behaviour is exhibited.

Apparently the battery block treats "Not charging" as "Full": https://github.com/greshake/i3status-rust/blob/0cccc595b5c9bac940687dbe7a9e6ab6d42f0006/src/blocks/battery.rs#L857
@ram02z What's the output of cat /sys/class/power_supply/BAT0/current_now?
Apparently the battery block treats "Not charging" as "Full":
https://github.com/greshake/i3status-rust/blob/0cccc595b5c9bac940687dbe7a9e6ab6d42f0006/src/blocks/battery.rs#L857
I can confirm that when I disconnect the AC, the percentage is shown. Note that I am using a battery charging threshold, so it never reaches 100% and only starts charging when below 60%.
@ram02z What's the output of cat /sys/class/power_supply/BAT0/current_now?
current_now doesn't exist for me.
I can confirm that when I disconnect the AC, the percentage is shown. Note that I am using a battery charging threshold, so it never reaches 100%.
Well, then the current output is correct?
I can confirm that when I disconnect the AC, the percentage is shown. Note that I am using a battery charging threshold, so it never reaches 100%.
Well, then the current output is correct?
Not really, because if I plug it when its above the charging threshold but below the full capacity, e.g. 70%, it will not show the percentage.

i3status-rust version: 0.21.2
Was it different in the previous versions?
Was it different in the previous versions?
I did try 0.20.7 and 0.20.4 again to check, but the behaviour is the same, however, I am pretty sure this behaviour is new since I have always seen the percentage. I did update my Linux kernel yesterday, so that might be it.
Anyway, I set full_format = "{percentage}" and it shows now (According to the docs, this should the default behaviour, but I have had to set it explicitly). I still think the behaviour is weird, because the battery is flagged as full when in its in the range charge_control_start_thresh_hold < x <= charge_control_end_threshold and plugged in.
So, in your case, battery should be considered full then it's 85% and above, discharging if it's between 60% and 85%, and charging if's below 60% and connected?
I did update my Linux kernel yesterday, so that might be it.
Most likely.
So, in your case, battery should be considered full then it's 85% and above, discharging if it's between 60% and 85%, and charging if's below 60% and connected?
Yeah, the issue occurs when my AC is plugged in and my battery level is between 60% and 85%, it doesn't charge, but it doesn't discharge; remains at the original battery level when it was plugged in.

Just to be sure, when the percentage drops to 60%, does the status change to "Charging"?
Just to be sure, when the percentage drops to 60%, does the status change to "Charging"?
I think so, since I remember the icon changing to have the charging symbol. I am currently discharging my battery, I'll update you when it is < 60%.
Also, it turns out that it was because of Linux 5.15.17. https://github.com/torvalds/linux/commit/dd7c1a93025284d244bb5b00108b7417df00e1df
I think so, since I remember the icon changing to have the charging symbol. I am currently discharging my battery, I'll update you when it is < 60%.
Okay, if this is the case, then I think the block should just set status to "Discharging" if charge_control_start_thresh_hold < x <= charge_control_end_threshold && status == "Not charging" ?
By the way, how does UPower handle this case?
busctl get-property org.freedesktop.UPower /org/freedesktop/UPower/devices/battery_BAT0 org.freedesktop.UPower.Device State
I think so, since I remember the icon changing to have the charging symbol. I am currently discharging my battery, I'll update you when it is < 60%.
Okay, if this is the case, then I think the block should just set status to "Discharging" if
charge_control_start_thresh_hold < x <= charge_control_end_threshold && status == "Not charging"?
Hmm, that would be better than "Full", but just "Not Charging" would be accurate.
By the way, how does UPower handle this case?

Hmm, that would be better than "Full", but just "Not Charging" would be accurate.
Like not_charging_format config option?
Hmm, that would be better than "Full", but just "Not Charging" would be accurate.
Like
not_charging_formatconfig option?
Yeah I can see that being useful.
Just to be sure, when the percentage drops to 60%, does the status change to "Charging"?
Yeah it does, when it is plugged in.
