mirror of
https://gitlab.freedesktop.org/upower/upower.git
synced 2025-12-20 05:30:03 +01:00
src: up-daemon: skip the battery if present = 0
If the battery is not present, skip it when estimating the battery percentage. Resolves: #292
This commit is contained in:
parent
eb5a327127
commit
6bd8cd90b3
1 changed files with 5 additions and 0 deletions
|
|
@ -156,6 +156,7 @@ up_daemon_update_display_battery (UpDaemon *daemon)
|
|||
|
||||
UpDeviceState state = UP_DEVICE_STATE_UNKNOWN;
|
||||
UpDeviceKind kind = UP_DEVICE_KIND_UNKNOWN;
|
||||
gboolean present = FALSE;
|
||||
gdouble percentage = 0.0;
|
||||
gdouble energy = 0.0;
|
||||
gdouble energy_full = 0.0;
|
||||
|
|
@ -166,6 +167,7 @@ up_daemon_update_display_battery (UpDaemon *daemon)
|
|||
|
||||
device = g_ptr_array_index (array, i);
|
||||
g_object_get (device,
|
||||
"is-present", &present,
|
||||
"type", &kind,
|
||||
"state", &state,
|
||||
"percentage", &percentage,
|
||||
|
|
@ -177,6 +179,9 @@ up_daemon_update_display_battery (UpDaemon *daemon)
|
|||
"power-supply", &power_supply,
|
||||
NULL);
|
||||
|
||||
if (!present)
|
||||
continue;
|
||||
|
||||
/* When we have a UPS, it's either a desktop, and
|
||||
* has no batteries, or a laptop, in which case we
|
||||
* ignore the batteries */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue