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

Bug #1100546 reported by Stephen Rees-Carter on 2013-01-16
98
This bug affects 18 people
Affects Status Importance Assigned to Milestone
indicator-power (Ubuntu)
Medium
Unassigned
Xenial
Medium
Unassigned

Bug Description

[Impact]

 * It's very annoying to see the mouse battery instead of the system battery on indicator bar.

[Test Case]

 * Using Logitech Wireless Mouse M325 or other wireless mouse can see this issue.

[Regression Potential]

 * No regression as I know.

[Other Info]

 * This is a SRU request for Ubuntu 16.04 (xenial).

The power indicator shows the battery level for cordless mice and keyboards, even when it cannot identify the battery level. This is a problem as it seems to favour showing a "not present" mouse status over the laptop battery level in the top bar.

I haven't done a good job of explaining it, so check out the screenshot - it will explain all :)

Basically, the laptop battery should be shown in the top bar if the mouse/keyboard is "not present".
Also hiding the mouse and keyboard when the battery level is unknown would also be useful too :)

ProblemType: Bug
DistroRelease: Ubuntu 13.04
Package: indicator-power 12.10.6daily12.11.21.1-0ubuntu1
ProcVersionSignature: Ubuntu 3.8.0-0.3-generic 3.8.0-rc3
Uname: Linux 3.8.0-0-generic x86_64
ApportVersion: 2.8-0ubuntu1
Architecture: amd64
Date: Thu Jan 17 10:11:16 2013
InstallationDate: Installed on 2012-12-14 (33 days ago)
InstallationMedia: Ubuntu 13.04 "Raring Ringtail" - Alpha amd64 (20121214)
MarkForUpload: True
SourcePackage: indicator-power
UpgradeStatus: No upgrade log present (probably fresh install)

Related branches

Stephen Rees-Carter (valorin) wrote :
Felix Möller (felix-derklecks) wrote :

I just wanted to report the same. Even though my mouse battery status can be read I am a lot more interested in my laptop battery.

Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in indicator-power (Ubuntu):
status: New → Confirmed
TJ (tj) wrote :

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.

How about marking anything that is connected over bluetooth as a secondary?

Changed in indicator-power:
assignee: nobody → Charles Kerr (charlesk)

I just updated to 13.10 and was hit by this bug, so I coded a patch that introduces a new configuration setting and menu alternative to prefer laptop batteries over other devices, regardless of (dis)charging status.

It's in this branch, based on 13.10 (since I didn't know if there might be incompatibilities with testing 14.04 code in a stock Ubuntu):
https://code.launchpad.net/~peter-liljenberg/indicator-power/prefer-battery-1100546

Matthew Paul Thomas (mpt) wrote :

Belated thanks to TJ for that good analysis.

I see two things going wrong here. First, "(not present)" should only be used for internal batteries; peripherals that aren't present shouldn't be shown at all. There are thousands of possible chargeable devices not present on your PC, so I don't know why the menu is singling out a mouse and a keyboard here! But I hadn't made that explicit in the specification, so I've done that now. <https://wiki.ubuntu.com/Power?action=diff&rev2=50&rev1=49>

Second, even when the menu does contain a "(not present)" component, it shouldn't end up as the primary device when any other devices are charging or discharging.

Both of those should be fixed, but if *either* was fixed, Stephen wouldn't have experienced the bug.

Peter, thanks for the proposal, but I don't think that would solve the problem. If someone connected their notebook to power and removed its battery, with your alternative they'd still see "not present" in the menu bar even when something more urgent was going on, like a wireless keyboard about to expire.

Changed in indicator-power (Ubuntu):
status: Confirmed → Triaged

Matthew, this was the closest bug I found for the problem I experienced in having a mouse indication that I don't care about (and others too: http://askubuntu.com/questions/361022/how-to-disable-mouse-power-status-in-indicator-power). If you know a better bug please point me to it, or I can write one.

Personally, I don't need notification if the keyboard or mouse is about to drop it's last little battery power, because worst-case I just have to flip the laptop lid open and use it that way. Gamers might feel different, so that's why I made it configurable.

Charles Kerr (charlesk) on 2014-03-13
Changed in indicator-power (Ubuntu):
assignee: nobody → Charles Kerr (charlesk)
Changed in indicator-power:
status: New → Triaged
importance: Undecided → Medium
Changed in indicator-power (Ubuntu):
importance: Undecided → Medium
Jochen Fahrner (jofa) wrote :

Is there a ppa or a debian package for download that contains Peters mod for 14.04?
It's very annoying to always see the mouse icon in indicator panel. I'm not interested in mouse status, I need to know if laptop battery is charging/discharging/full and if I'm running on AC. This information is lost when the mouse indicator wins. :-(

Gerry Boland (gerboland) wrote :

Why can't I just see multiple battery indicators in my panel? One for each peripheral? With a way to hide ones I don't care about?

Matthew Paul Thomas (mpt) wrote :

We try to stick to a rule that each indicator has one icon and/or one piece of text. If we diverged from that, it would be harder to tell when every indicator ended and the next began.

Sune Woeller (sune-woeller) wrote :

it is critical on a laptop to be able to see wether the laptop battery is running low with a glance. Showing keyboard/mouse battery instead of laptop battery status obscures this vital info.

peddanet (peter-wein) wrote :

@Gerry Boland, I am fan of your solution! This can't be this hard to implement!!

peddanet (peter-wein) wrote :

Does anybody know, where to find the source code for that?

peddanet (peter-wein) wrote :

Ok, I am sorry for that question! Mea culpa...

Pieter (pietersmit) wrote :

The Ubuntu Wiki page at https://wiki.ubuntu.com/Power#settings seems to say that if the mouse battery is low, then it gets the battery indicator. In my opinion, this is fundamentally incorrect behaviour.
If the PC has a battery then it is likely to be a laptop and therefore it's more important to display the laptop battery level instead of the mouse battery.
I care if my laptop battery is about to go flat. I don't care at all if my mouse battery is only at 29% because my mouse will probably continue to work for many weeks whereas my laptop only works for a couple of hours from 100%.
It would be better if there was a way to choose which battery level to display or have a way to completely ignore mouse battery readings.

Shih-Yuan Lee (fourdollars) wrote :

I encounter the same problem on Ubuntu 16.04 so I made this patch.

Shih-Yuan Lee (fourdollars) wrote :

I also created https://launchpad.net/~fourdollars/+archive/ubuntu/lp1100546 for Ubuntu 16.04.
You can try it on your own system to see if this patch works or not.

Shih-Yuan Lee (fourdollars) wrote :

Oops, sorry that I disabled the unit tests locally so it can not be built in PPA yet.

The attachment "indicator-power_12.10.6+16.04.20160105-0ubuntu1.debdiff" seems to be a debdiff. The ubuntu-sponsors team has been subscribed to the bug report so that they can review and hopefully sponsor the debdiff. If the attachment isn't a patch, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are member of the ~ubuntu-sponsors, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issue please contact him.]

tags: added: patch
Shih-Yuan Lee (fourdollars) wrote :

This patch passed the unit tests.

Shih-Yuan Lee (fourdollars) wrote :

This patch is for zesty.

Launchpad Janitor (janitor) wrote :

This bug was fixed in the package indicator-power - 12.10.6+17.04.20170116-0ubuntu1

---------------
indicator-power (12.10.6+17.04.20170116-0ubuntu1) zesty; urgency=medium

  [ Shih-Yuan Lee (FourDollars) ]
  * Make device with power supply has higher sorting priority. (LP: #1100546)

 -- <email address hidden> (<email address hidden>) Mon, 16 Jan 2017 20:29:09 +0000

Changed in indicator-power (Ubuntu):
status: Triaged → Fix Released
description: updated
tags: added: xenial
Changed in indicator-power (Ubuntu Xenial):
importance: Undecided → Medium
affects: indicator-power → ubuntu-translations
Changed in ubuntu-translations:
assignee: Charles Kerr (charlesk) → nobody
no longer affects: ubuntu-translations
Michael Terry (mterry) wrote :

Thanks $4 for the patches! But the patch for 16.04 does not apply cleanly. It tries to patch src/device-provider-upower.c which does not exist.

I'll drop the sponsor team subscription for now; if a fixed patch is uploaded, please re-add them.

Shih-Yuan Lee (fourdollars) wrote :

But src/device-provider-upower.c does exist. That's weird. Could you check it again?

Amr Ibrahim (amribrahim1987) wrote :

Ping!

Charles Kerr (charlesk) on 2017-05-29
Changed in indicator-power (Ubuntu):
assignee: Charles Kerr (charlesk) → nobody
Simon Quigley (tsimonq2) wrote :

Echoing what Michael said in #24, unsubscribing ~ubuntu-sponsors. Please feel free to resubscribe and leave a comment if this was done in error.

Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in indicator-power (Ubuntu Xenial):
status: New → Confirmed
jack peter (jackpeter7278) wrote :

The mouse is one of the most important parts of a laptop and it plays a role of the indicator and helps us to swipe the cursor over the monitor, but if you are having an issue with the mouse, then https://epsonsupports.net/blog/epson-printer-not-printing/ will help you a lot in this regarding.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers