mirror of
https://codeberg.org/dnkl/yambar.git
synced 2025-04-20 03:35:41 +02:00
battery: correct time_to_empty calculation
The kernel docs state that time_to_empty contains the estimation of remaining time in seconds. Hence, calculate estimate minutes and hours from that in a more correct way. Signed-off-by: David Bimmler <git@d4ve.email>
This commit is contained in:
parent
d236b9c1b9
commit
08f5f444eb
2 changed files with 4 additions and 2 deletions
|
@ -52,6 +52,7 @@
|
||||||
* pipewire: use roundf instead of ceilf for more accuracy ([#262][262])
|
* pipewire: use roundf instead of ceilf for more accuracy ([#262][262])
|
||||||
* Crash when a yaml anchor has a value to already exists in the target
|
* Crash when a yaml anchor has a value to already exists in the target
|
||||||
yaml node ([#286][286]).
|
yaml node ([#286][286]).
|
||||||
|
* battery: Fix time conversion in battery estimation ([#303][303]).
|
||||||
|
|
||||||
[239]: https://codeberg.org/dnkl/yambar/issues/239
|
[239]: https://codeberg.org/dnkl/yambar/issues/239
|
||||||
[241]: https://codeberg.org/dnkl/yambar/issues/241
|
[241]: https://codeberg.org/dnkl/yambar/issues/241
|
||||||
|
|
|
@ -86,8 +86,9 @@ content(struct module *mod)
|
||||||
unsigned long minutes;
|
unsigned long minutes;
|
||||||
|
|
||||||
if (m->time_to_empty >= 0) {
|
if (m->time_to_empty >= 0) {
|
||||||
hours = m->time_to_empty / 60;
|
minutes = m->time_to_empty / 60;
|
||||||
minutes = m->time_to_empty % 60;
|
hours = minutes / 60;
|
||||||
|
minutes = minutes % 60;
|
||||||
} else if (m->energy_full >= 0 && m->charge && m->power >= 0) {
|
} else if (m->energy_full >= 0 && m->charge && m->power >= 0) {
|
||||||
unsigned long energy = m->state == STATE_CHARGING
|
unsigned long energy = m->state == STATE_CHARGING
|
||||||
? m->energy_full - m->energy : m->energy;
|
? m->energy_full - m->energy : m->energy;
|
||||||
|
|
Loading…
Add table
Reference in a new issue