From 522fdc6abbfee52dec5c6b0194cf87ffcc0f3dcd Mon Sep 17 00:00:00 2001 From: Marc Deslauriers Date: Tue, 2 Jun 2015 19:18:22 -0400 Subject: Don't prioritize discharging items with no time estimate that have more than 10% power remaining. Devices with no time estimates are most likely low-power devices that have long-lasting batteries, such as a mouse with AA batteries. For those type of devices that contain batteries that last weeks, there is no value in displaying their status in preference to devices that have a rapid charge/discharge cycle. However, there is value in knowing if the device has a battery that needs replacing imminently, so only display it if it falls to a 10% charge or under. --- src/service.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/service.c b/src/service.c index c93c4b6..73fcf46 100644 --- a/src/service.c +++ b/src/service.c @@ -162,12 +162,12 @@ get_device_kind_weight (const IndicatorPowerDevice * device) } /* sort devices from most interesting to least interesting on this criteria: - 1. device that supplied the power to the system - 2. discharging items from least time remaining until most time remaining - 3. charging items from most time left to charge to least time left to charge - 4. charging items with an unknown time remaining - 5. discharging items with an unknown time remaining - 6. batteries, then non-line power, then line-power */ + 1. discharging items from least time remaining until most time remaining + 2. charging items from most time left to charge to least time left to charge + 3. charging items with an unknown time remaining + 4. discharging items with an unknown time remaining, but 10% or below + 5. batteries, then non-line power, then line-power + 6. discharging items with an unknown time remaining, but above 10% */ static gint device_compare_func (gconstpointer ga, gconstpointer gb) { @@ -199,6 +199,14 @@ device_compare_func (gconstpointer ga, gconstpointer gb) } state = UP_DEVICE_STATE_DISCHARGING; + + /* discharging items with more than 10% remaining always lose */ + if (!ret && (((a_state == state) && !a_time && (a_percentage > 10)))) + ret = 1; + + if (!ret && (((b_state == state) && !b_time && (b_percentage > 10)))) + ret = -1; + if (!ret && (((a_state == state) && a_time) || ((b_state == state) && b_time))) { -- cgit v1.2.3