Bug 251618 - sysutils/battmond: battmond won't act if battery level suddenly drops to zero
Summary: sysutils/battmond: battmond won't act if battery level suddenly drops to zero
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Alexandre C. Guimarães
Depends on:
Reported: 2020-12-05 20:40 UTC by dirtystickyfloor
Modified: 2021-04-11 13:15 UTC (History)
2 users (show)

See Also:
dirtystickyfloor: maintainer-feedback-

proposed patch (418 bytes, text/plain)
2020-12-05 20:40 UTC, dirtystickyfloor
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description dirtystickyfloor 2020-12-05 20:40:18 UTC
Created attachment 220292 [details]
proposed patch

I configured battmond to suspend (option -z) after reaching a threshold of 5% (-H 5). In some cases, e.g. when running the system under high load and/or if the battery becomes old, it is not unusual that the battery level drops suddenly from more than 5 percent to zero percent. In this case the system will shut off unexpectedly instead of going to sleep. This is because battmond checks for remaining capacity greater than zero and not greater than or equal to zero (Line 192 in battmond.c).

Patchfile attached.
Comment 1 commit-hook freebsd_committer 2021-04-11 13:14:30 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=b64f1988e365b12baed8efb0e99a07299f8741e2

commit b64f1988e365b12baed8efb0e99a07299f8741e2
Author:     Alexandre C. Guimarães <rigoletto@FreeBSD.org>
AuthorDate: 2021-04-11 13:08:15 +0000
Commit:     Alexandre C. Guimarães <rigoletto@FreeBSD.org>
CommitDate: 2021-04-11 13:08:15 +0000

    sysutils/battmond: Fix battmond dies after first suspend

    - Fix won't acting if battery level suddenly drops to zero
    PR:             251618 251619
    Submitted by:   dirtystickyfloor@web.de
    Approved by:    ntarmos@gmail.com (maintainer timeout, 127 days)

 sysutils/battmond/files/patch-battmond.c (new) | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
Comment 2 Alexandre C. Guimarães freebsd_committer 2021-04-11 13:15:33 UTC
Committed. Thanks. :-)