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

Battery block with TLP #875

Closed evalexpr closed 3 years ago

evalexpr commented 3 years ago

Using TLP allows you to set charging thresholds for laptop batteries. I'm currently using this on a ThinkPad t14s.

I currently have the settings below:

START_CHARGE_THRESH_BAT0=85
STOP_CHARGE_THRESH_BAT0=90

Meaning that when the battery reaches 90% it stops charging and is considered full.

The values for the actual filesystem BAT0 status is Unknown - and looking at the code it doesn't seem we care about handling this case at the moment.

Currently when using i3status-rust my block just gets "stuck" at 89/90%, but using py3status or i3status, it's possible to set either status_unk or threshold_full in order to work alongside the charge stop threshold setting.

I'm curious if it's something you'd want to consider supporting? or if there is currently a way around this at the moment? (had a look at the code but can't see any).

Thanks!

ammgws commented 3 years ago

PRs welcome

Nukesor commented 3 years ago

I like the idea. Still, this should probably only an optional feature. Personally, I like to know at which (absolute) percentage my battery is currently hovering.

@evalexpr I'm curious. When using py3status/i3status and setting a custom threshold_full, does it always reach 100%? Using your example above, the current percentage might still be stuck at, for instance, 96% "relative" percent whenever you manage to discharge it just a little, without reaching the charge threshold.

evalexpr commented 3 years ago

@Nukesor it would be an optional feature since it'd be implemented in the same was as py3status/i3status meaning that you could specify a threshold_full value or something to indicate the value you want the bar to display the "full" icon at, i.e. I specify 90, when my battery is at 90% the full battery icon is shown. If you don't specify this then it'd behave as normal

I'm unsure what you mean by "does it always reach 100%" by definition when using TLP my battery will never reach 100% and instead stops at 90, the difference with py3status/i3status as mentioned above is that the bar will show my battery as full at 90%.

Nukesor commented 3 years ago

Perfect :)

What I mean with "does it always reach 100%":

For instance, when setting threshold_full to 90% the status bar will show 100%, if the physical capacity reaches 90%.

However, since TLP allows to set a start and stop threshold as already mentioned by you, it will happen that the physical capacity sticks at e.g. 87%. (85% start, 90% stop, You started discharging from 90%, but plugged power in back at 87% -> Won't charge up to 90%).

This would result in the bar showing ~97%, even though the battery is no longer actively changing.

GladOSkar commented 3 years ago

Regarding the discussion in this thread: My implementation simply switches to display the full_format when the threshold is reached and would not re-scale the percentage to show 100% at the threshold.

I.e. this would show 88% -> 89% -> Full -> 89% -> 88% at a threshold of 90.

ammgws commented 2 years ago

@evalexpr Have you tried #1261?