mirror of
https://gitlab.freedesktop.org/upower/upower.git
synced 2026-04-20 13:00:40 +02:00
If a power-supply device doesn't report charge or energy, try to read the percentage
This commit is contained in:
parent
46f1c7f028
commit
d4ea1cb566
1 changed files with 8 additions and 1 deletions
|
|
@ -40,7 +40,7 @@
|
|||
#define UP_DEVICE_SUPPLY_REFRESH_TIMEOUT 30 /* seconds */
|
||||
#define UP_DEVICE_SUPPLY_UNKNOWN_TIMEOUT 2 /* seconds */
|
||||
#define UP_DEVICE_SUPPLY_UNKNOWN_RETRIES 30
|
||||
#define UP_DEVICE_SUPPLY_CHARGED_THRESHOLD 90.0f /* % */
|
||||
#define UP_DEVICE_SUPPLY_CHARGED_THRESHOLD 90.0f /* % */
|
||||
|
||||
#define UP_DEVICE_SUPPLY_COLDPLUG_UNITS_CHARGE TRUE
|
||||
#define UP_DEVICE_SUPPLY_COLDPLUG_UNITS_ENERGY FALSE
|
||||
|
|
@ -703,6 +703,13 @@ up_device_supply_refresh_battery (UpDeviceSupply *supply)
|
|||
percentage = 100.0f;
|
||||
}
|
||||
|
||||
/* device is a peripheral and not providing power to the computer */
|
||||
if (energy < 0.01f &&
|
||||
energy_rate < 0.01f &&
|
||||
energy_full < 0.01f) {
|
||||
percentage = sysfs_get_double (native_path, "CAPACITY");
|
||||
}
|
||||
|
||||
/* the battery isn't charging or discharging, it's just
|
||||
* sitting there half full doing nothing: try to guess a state */
|
||||
if (state == UP_DEVICE_STATE_UNKNOWN) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue