Battery charge start and stop threshold on OpenBSD
I often use my laptops as portable desktops: they are plugged into AC power and an external monitor/keyboard 95% of time. Unfortunately, continuous charging is hard on the battery. To mitigate this, ThinkPads have customizable start and stop charging thresholds, such that the battery will only start charging if its level falls below the start threshold, and it will stop charging as soon as it reaches the stop threshold. Suggested thresholds from Lenovo’s battery team can be found in this comment.
You can set these thresholds on Linux using
tlp-stat(8), and you can make the values persist across
reboots by setting START_CHARGE_THRESH_BAT0
and
STOP_CHARGE_THERSH_BAT0
in /etc/tlp.conf
.
I recently installed OpenBSD on my work ThinkPad, but struggled to
find any information on how to set the thresholds under OpenBSD. After
only finding a dead-end thread from 2021 on misc@, I started
digging around on how to implement it myself. The acpithinkpad
and
acpibat
drivers looked promising, and a bit of Google-fu lead me to
the following small announcement in the OpenBSD 7.4 release
notes:
New sysctl(2) nodes for battery management, hw.battery.charge*. Support them with acpithinkpad(4) and aplsmc(4).
Lo and behold, setting the start and stop threshold in OpenBSD is
simply a matter of setting hw.battery.chargestart
and
hw.battery.chargestop
with sysctl
. The documentation was not
committed in time for the 7.4 release, but you can read it in
-CURRENT’s sysctl(2)
. I personally set the following values
in /etc/sysctl.conf
:
hw.battery.chargestart=40
hw.battery.chargestop=60
Comments: To comment on this post, send me an email following the template below. Your email address will not be posted, unless you choose to include it in the link: field. If your web browser is configured to handle mailto: links, click comment to load the template into your mail client.
To: Ryan Kavanagh <rak@rak.ac> Subject: [blog-comment] /blog/2023-12-20-battery-charge-start-stop-threshold-on-openbsd/ post_id: /blog/2023-12-20-battery-charge-start-stop-threshold-on-openbsd/ author: [How should you be identified? Usually your name or "Anonymous"] link: [optional link to your website] Your comments here. Markdown syntax accepted.
0 Comments