After resuming from suspend, all batteries are added
to powerdevil. When a battery, with charge lower or
equal than the critical charge percentage is added, the
critical battery timer will be started.
In the current version the critical battery timeout can
only be interrupted by plugging in AC.
But if the system has more than one battery, the global
charge percentage can be greater than the critical charge
percentage and so the system shouldn't suspend. To achive
this behaviour, we calculate the global charge percentage
whenever a new battery was added and if the critical
battery timer is running and the global charge is high
enough, we stop the timer.
Also we use the already calculated global charge percentage
for the battery charge percentage notification instead of
the charge of each individual battery.
With this patch, the user can not only interrupt the critical
timer by plugging in the AC but also by plugging in a new or
additional battery (if the battery has enough charge).
The patch for kde:powerdevil will move the calculation of
the global charge percentage into a new function to avoid
the code duplication, but for the KDE/4.11 version I have
avoided this to keep the number of changes as small as
The 30 sec timeout message will still popup. Any ideas
how to avoid this? Showing an additional message is not
a solution in this case because of the message freeze.
Testing was done by Philipp Paris on his Thinkpad T440s (two
Two batteries above critical section:
Resume after suspend works without the 30 sec timeout. (as current version)
One battery in critical section and the other above:
Resume after suspend works without the 30 sec timeout. (changed behaviour)
Both in critical section:
Resume after suspend without plugged in AC will go sleeping
in 30 sec. (as current version)