Preserving Battery Power on an OpenBSD Laptop
With the addition
of the hw.setperf sysctl, it is possible to control a laptop’s
CPU speed,
reducing its power usage and increasing its battery life.
But who has time to manually speed up or slow down their
CPU?
Luckily, apmd(8)
can do certain things when the laptop gets plugged in or unplugged.
This allows us to conserve battery power when the laptop is running
on its battery, and run at the laptop’s maximum speed when it is
running on its A/C adapter.
Here’s what you need to do:
- Enable apmd. (Either in /etc/rc.conf or
sudo apmd.) # mkdir -p /etc/apm- Add the line
/sbin/sysctl hw.setperf=0to /etc/apm/powerdown. - Add the line
/sbin/sysctl hw.setperf=100to /etc/apm/powerup. - Make both executable:
# chmod a+x /etc/apm/*
This is what my laptop shows when plugged in:
$ sysctl hw.setperf
hw.setperf=100
$ apm
Battery state: high
Battery remaining: 94 percent
Battery life estimate: 0 minutes
A/C adapter state: connected
Power management enabled
Unplugged:
$ sysctl hw.setperf
hw.setperf=0
$ apm
Battery state: high
Battery remaining: 94 percent
Battery life estimate: 446 minutes
A/C adapter state: not connected
Power management enabled
Yay.