i3 / i3/i3status

0% battery reported because _AVG postfix is ignored in battery uevent

Open
#452 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
653
Forks
254
PR merge metrics
No merged PRs in 30d

Description

**Issue:**

The battery_info module reports 0% for some battery power supply drivers. This is because the `_AVG` postfix is not handled.

**Detail:**

According to the specification laid out in https://www.kernel.org/doc/Documentation/power/power_supply_class.txt, battery uevent can report values with two potential postfixes:

> Postfixes:
> _AVG - *hardware* averaged value, use it if your hardware is really able to
> report averaged values.
> _NOW - momentary/instantaneous values.

Currently only the `_NOW` postfix is handled, so drivers that report hardware averaged values and not momentary/instantaneous values will not work.

This breaks when used with the pmu_battery module on Apple iBooks. For example, the iBook Clamshell with pmu_battery exports this uevent at `/sys/class/power_supply/PMU_battery_0/uevent`:

```
POWER_SUPPLY_NAME=PMU_battery_0
POWER_SUPPLY_TYPE=Unknown
POWER_SUPPLY_STATUS=Charging
POWER_SUPPLY_PRESENT=1
POWER_SUPPLY_MODEL_NAME=Smart
POWER_SUPPLY_ENERGY_AVG=391000
POWER_SUPPLY_ENERGY_FULL=3965000
POWER_SUPPLY_CURRENT_AVG=1204000
POWER_SUPPLY_VOLTAGE_AVG=14432000
POWER_SUPPLY_TIME_TO_EMPTY_AVG=10686
```

The following code should probably be modified to handle the `_AVG` postfix, and prioritize the `_AVG` postfix version over the `_NOW` postfix version:

https://github.com/i3/i3status/blob/30a32cce3a16e6c79a81aad467cfe13c12e688cb/src/print_battery_info.c#L155-L200

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.