Battery State displays your FreeBSD laptop battery status in text styleat

Usage

The Battery State application can be integrated in any WM application who accepts text style output like wmii, ratpoison and many others. The application was wrote for FreeBSD in plain C and uses the sysctl interface to query the battery state.

Screenshots

Integration in the Wmii status bar

Connected to the AC power

Disconnected from the AC power

Download

battery.c : Download the source code

License

The code is delivered under BSD License

Implementation details

The information about the battery state are provided by the “hw.acpi.battery.life” sysctl.
Those values are the power remaining in the battery in percent, and the charging state as a numeric value as displayed in the following array.

ValueStateDescription
1 Discharging We are using the battery
2 Charging We are charging the battery
4 Critical something really weird, but what
7 Not present / max another unknown state

Notes about status :

  • If the battery is full and we are using the AC power the status value is 0
  • If we disconnect the AC power, the status value is 2
  • If the battery is not full, and we connect the AC power the status is 2