i3 / i3status

Generates status bar to use with i3bar, dzen2 or xmobar
BSD 3-Clause "New" or "Revised" License
598 stars 251 forks source link

Add another battery status called 'idle' #486

Closed erbth closed 1 year ago

erbth commented 2 years ago

Hi everyone,

I would like to add another state to the battery-module called 'idle'. My ThinkPad has a configurable charging regulator that can be instructed to stop charging before the battery is full. Recently a Linux-kernel patch got merged s.t. this state is now correctly reported as "Not charging" by the kernel (before it was "Unknown").

However since #305 this status is mapped to "Discharging". Please have a look at https://github.com/i3/i3status/pull/461#issuecomment-1064700361, where I tried to describe why I think my proposed behavior would be better, and why I think that it would in principle also be better than the proposed change in #461. In my comment I wrote that a mechanism to customize i3status's behavior for "Not charging" might be needed, however I think the mechanism for changing the texts mapped to states through i3status.conf might be enough.

Of course, this PR covers only the foundation and Linux-specific implementation. Support for other OSs would have to be added afterwards if possible, however I cannot assist in that.

Regards, Thomas

erbth commented 2 years ago

I am not sure how this interacts with #304; one would have needed more information on the original problem. If you have any doubts regarding that or anything else in this PR, please request a change.

erbth commented 1 year ago

fyi just rebased to current main

thrasymache commented 1 year ago

I have a system76 laptop which also lets me set a charging threshold. Mine ends up reporting UNK/Unknown along with 0.00W when it reaches this threshold. The current patch doesn't appear to make things better for me, but it also clearly doesn't make them worse.

erbth commented 1 year ago

@thrasymache thanks for testing! - Yeah, unfortunately the hardware and kernel driver need to report that state as 'Not charging', too. It looks like yours does not - if you like, you could confirm that with cat /sys/class/power_supply/BAT0/status (if you are on Linux) while the laptop is in the non-charging state.

thrasymache commented 1 year ago

@erbth The contents of the BAT0/status pseudo-file are Unknown

erbth commented 1 year ago

@thrasymache Then your driver (or hardware) does not support reporting the idle-state correctly. Good to know.

Mine (ThinkPad) shows e.g. "Not charging". Of course that depends on the kernel version, too (e.g. the acpi-driver used by mine got support only recently, currently I'm on Debian's 5.10.149-1).

erbth commented 1 year ago

thanks for merging