The order is dictated by src/indicator-power.c. All power devices are
assigned a weighting, with batteries assigned weight 2, in function:

static int
get_device_kind_weight(const IndicatorPowerDevice * device) {...}


A function sorts all power devices in a list according to this criteria:


/* sort devices from most interesting to least interesting on this criteria:
   1. discharging items from least time remaining until most time remaining
   2. discharging items with an unknown 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. batteries, then non-line power, then line-power */
static gint
device_compare_func (gconstpointer ga, gconstpointer gb) {...}


Finally, the primary device is selected as the first in the sorted list:


IndicatorPowerDevice *
indicator_power_choose_primary_device (GSList * devices) {
...
      tmp = g_slist_sort (tmp, device_compare_func);
      primary = g_object_ref (tmp->data);
...
  return primary;
}


Examining /sys/class/power_supply/*/ it looks as if the sort function could 
take into account the 'capacity' node of all batteries since it looks to be the 
only common value shared across laptop and external device batteries. I've not 
yet discovered the unit of measure so far though, so it might not be the most 
suitable value.

$ for n in /sys/class/power_supply/*/capacity; do echo "$n $(cat $n)"; done
/sys/class/power_supply/BAT0/capacity 116
/sys/class/power_supply/hid-00:12:a1:63:a8:50-battery/capacity 63


The key thing is to be able to recognise and differentiate the treatment of 
internal laptop batteries (of which there can be more than one) from external 
device batteries (mice, keyboard, headphones, etc.).

It may be that the simplest most flexible solution would be to add an
option to the Power Settings GUI that allows the user to make an
intelligent decision as to which battery/batteries they wish to be
considered as the primaries for purposes of the indicator icon.

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1100546

Title:
  Power indicator favours 'not present' mouse over laptop battery level

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/indicator-power/+bug/1100546/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to