diff --git a/CHANGELOG.md b/CHANGELOG.md index 48373d6..cd36c33 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -52,6 +52,7 @@ * 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 yaml node ([#286][286]). +* battery: Fix time conversion in battery estimation ([#303][303]). [239]: https://codeberg.org/dnkl/yambar/issues/239 [241]: https://codeberg.org/dnkl/yambar/issues/241 diff --git a/modules/battery.c b/modules/battery.c index db00add..2b04d65 100644 --- a/modules/battery.c +++ b/modules/battery.c @@ -86,8 +86,9 @@ content(struct module *mod) unsigned long minutes; 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) { unsigned long energy = m->state == STATE_CHARGING ? m->energy_full - m->energy : m->energy;