Skip to content

battery warning level for FreeBSD control method batteries.

Notifications You must be signed in to change notification settings

random532/FreeBSD_Battery_Trip_Point

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 
 
 

Repository files navigation

FreeBSD Battery Warnings

Affected file:
sys/dev/acpica/acpi_cmbat.c


Short description:
You don't need to poll the battery periodically.
You can set a percentage (ranging from 0-100) via sysctl.
This causes a /dev/devd event Notify(0x80). So a script can be triggered.

Long description:
ACPI specification defines an optional acpi method called "_BTP".
Currently the FreeBSD cmbat driver only supports mandatory methods (bif, bix, ..), but no optional ones.

Try the command: "acpidump -dt |grep _BTP". If it returns something, your battery supports this function.

If supported by the battery, a new sysctl is created: dev.battery.X.Warning_Level
Replace the X with your battery index (0, 1, ...).

You can set the warning level ("trip point") with this sysctl (values between 0-100 are allowed).
If the battery reaches that percentage, devd will be notified.

Add an entry in /etc/devd.conf:
notify 10 {
match "system" "ACPI";
match "subsystem" "CMBAT";
action "/home/myuser/myscript.sh $notify";
};

Replace myuser with your local user. Replace myscript.sh with a script of your choice.

Personal note: If you have any questions, please write me. I will look at this again.
Thanks. :-)

Installation guide for beginners:

Step 1: Try the command: "acpidump -dt |grep _BTP". If it returns something, your battery supports this function.

Step 2: Donwload the Freebsd source code.
Replace the file from this repo with the file /usr/src/sys/dev/acpica/acpi_cmbat.c

Step 3: Build and install the new kernel.

Step 4: Add an entry in /etc/devd.conf:
notify 10 {
match "system" "ACPI";
match "subsystem" "CMBAT";
action "/home/myuser/myscript.sh $notify";
};

Step 5: Replace mysuser and myscript with an actual user and an actual script.

Step 6: Set the sysctl dev.battery.0.Warning_Level to your desired warning level. If it works, give me feedback.

About

battery warning level for FreeBSD control method batteries.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages