aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarc Deslauriers <marc.deslauriers@canonical.com>2015-06-02 19:18:22 -0400
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2021-08-28 10:17:14 +0200
commit522fdc6abbfee52dec5c6b0194cf87ffcc0f3dcd (patch)
tree217cacf338c2f3b15f8650b58048547080ed0c58 /src
parent6fbccd32e945d5499d0bb06812ef0c129e621c95 (diff)
downloadayatana-indicator-power-522fdc6abbfee52dec5c6b0194cf87ffcc0f3dcd.tar.gz
ayatana-indicator-power-522fdc6abbfee52dec5c6b0194cf87ffcc0f3dcd.tar.bz2
ayatana-indicator-power-522fdc6abbfee52dec5c6b0194cf87ffcc0f3dcd.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/service.c20
1 files 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)))
{