Power management does not recognize removal of power supply! [duplicate]

Solution 1:

I have a Lenovo Z470 notebook and I found the same problem when installing Ubuntu 12.04 in dual boot with Windows 7. I'm not an expert on this field but I'll describe my experience (it might help).

I have found that some Lenovo laptops, including my own and I'm not sure which other models, include an utility named Lenovo Energy Management in Windows 7 that allows users to select whether to charge to 100% to maximize runtime, or charge only partially to maximize lifespan of the battery.

Here is what the utility looks like: Screenshot of the Lenovo Energy Management utility in Windows

Pertaining this utility I have noticed two things:

  1. In Ubuntu, in order to be able to charge the battery to 100% the Optimize for Battery Runtime must have been selected previously in Windows 7 (I don't know if this can be controlled from Ubuntu directly, perhaps an expert could help us in that issue).
  2. Now the bigger problem is that once you have selected the Optimize for Battery Lifespan option, even if it was only one time and you select the Optimize for Battery Runtime option again before booting Ubuntu, the Ubuntu battery indicator will indicate the battery is charging even if the power supply is not connected to the computer. So, in order to prevent this from happening you should avoid using the Lenovo Energy Management utility if you plan to use Ubuntu afterward, either clean install or dual boot.

Since most of us have already used this option at least once, I have found a workaround proposed in a thread in ubuntuforums.org proposed by member achilleas.k (not my credit). I'll cite:

Shut down the laptop.

Remove AC power.

Remove the battery.

Hold the power button for about 10 seconds.

This seemed to work for achilleas.k, some other users in that forum, and certainly is working for me. I know it's not a permanent solution, especially for those of us using both Ubuntu and Windows, but it sure helps meanwhile. Perhaps a more expert Linux user can help us out to find a formal solution using this info.

Hope it helps.

Solution 2:

I'm having the same problem, and as I didn't found the answer in these forums I decided to look somewhere else.

I found this page with an apparent explanation of the problem (seems to be something kernel related) and a possible workaround: https://lists.fedoraproject.org/pipermail/power-management/2012-April/000043.html

When I plug/unplug ac adapter, upower doesn't report that it's state changed, kde's power manager doesn't switch profiles. If I start with ac adapter plugged in and then unplug it, battery indicator shows that battery is discharging, but ac adapter is plugged in. Battery state is reported correctly. This problem exists in every linux distribution I tried for every kernel version from 2.6 to 3.4. Also it seems that this bug affects many people (open bugs in kde, upower bugtrackers).

I found a workaround and I think I must share it. I rebuilt kernel with ACPI_PROCFS_POWER=y ("Deprecated power /proc/acpi directories") and noticed that if I do "cat /proc/acpi/ac_adapter/AC/state" then state of the adapter becomes correct in kde, upower's output, etc.

I added a file to /etc/acpi/events/ with following contents: event=battery action=cat /proc/acpi/ac_adapter/AC/state > /dev/null

After restarting acpid everything works. The only problem is that ACPI_PROCFS_POWER is deprecated. I hope this bug will be fixed before the option will be removed.

The problem is that I'm a newbie with Ubuntu, and I don't really understand the concept of "rebuild kernel" posted above. So I'll leave this here and wait for some advanced user to enlighten us.

Solution 3:

alexio's information gave me enough information to figure out what to search for. This appears to be a kernel problem and I've found some similar bugs reported here:

  • https://bugs.launchpad.net/ubuntu/+source/upower/+bug/467825
  • https://bugs.launchpad.net/ubuntu/+source/gnome-power-manager/+bug/733866
  • https://bugs.launchpad.net/ubuntu/+source/acpi/+bug/878776

The closest bug I can find upstream is this one:

  • https://bugzilla.gnome.org/show_bug.cgi?id=611555

The only work around I can think of is check your battery statistics directly from the system instead of via the indicator like outlined in this question:

  • How to check battery status using terminal?

And then subscribe to the bug closest to your problem to follow along:

  • How do I subscribe to a bug?