summaryrefslogtreecommitdiff
path: root/src/linux/up-device-supply.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/linux/up-device-supply.c')
-rw-r--r--src/linux/up-device-supply.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/linux/up-device-supply.c b/src/linux/up-device-supply.c
index d272e36..0c17f94 100644
--- a/src/linux/up-device-supply.c
+++ b/src/linux/up-device-supply.c
@@ -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) {