Merge ~omattos/ubuntu/+source/initramfs-tools:omattos-resume-battery-level into ubuntu/+source/initramfs-tools:ubuntu/devel

Proposed by Oliver Mattos
Status: Needs review
Proposed branch: ~omattos/ubuntu/+source/initramfs-tools:omattos-resume-battery-level
Merge into: ubuntu/+source/initramfs-tools:ubuntu/devel
Diff against target: 42 lines (+25/-0)
1 file modified
scripts/local-premount/resume (+25/-0)
Reviewer Review Type Date Requested Status
Steve Langasek (community) Needs Fixing
git-ubuntu developers Pending
Review via email: mp+397351@code.launchpad.net

Commit message

Check battery level before resume from hibernate.

To post a comment you must log in.
Revision history for this message
Oliver Mattos (omattos) wrote :

Any update on this?

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

Hi, this looks almost right although I'm not sure the logic is 100% right. I'm also not sure who really should be reviewing this though -- desktop maybe? Is there a bug report about this that should be referenced?

Revision history for this message
Steve Langasek (vorlon) wrote :

Michael posted comments on the diff that have not been addressed. Marking as such.

review: Needs Fixing
Revision history for this message
Oliver Mattos (omattos) wrote :

Since making this and using it for ~2 years, I have discovered a few laptop models which have buggy battery state reporting mechanisms. They can stop updating the OS as to the battery state and level (I suspect because the embedded controller has crashed? - or maybe dodgy connections to a removable battery).

Anyway - the end result is that this patch makes those models of laptop unusable, because even when the user plugs in a power supply, the battery remains in the "3% charge, discharging, no AC" state, and the system won't boot.

This patch is therefore on hold until someone adds some kind of way to easily bypass the warning, and that requires plymouth to have better support for user interaction.

Unmerged commits

7cd1108... by Oliver Mattos <email address hidden>

Check battery level before resume from hibernate.

Issue: If an Ubuntu laptop has a battery get to a critical low level, it
will hibernate eventually.

If the system is then powered on again without being recharged, the resume
process will occur and the system will run out of battery a few seconds later.
This destroys the users state.

This patch causes the resume to be delayed until the battery is no longer
discharging and at a low level. The user will be notified on the boot
screen, and the resume process will auto-continue if a power supply is
attached.

84fbfef... by Guilherme G. Piccoli

0.137ubuntu12 (patches unapplied)

Imported using git-ubuntu import.

6119d3f... by Guilherme G. Piccoli

0.137ubuntu11 (patches unapplied)

Imported using git-ubuntu import.

d7c7790... by Alfonso Sanchez-Beato

0.137ubuntu10 (patches unapplied)

Imported using git-ubuntu import.

66eec50... by Dimitri John Ledkov

0.137ubuntu9 (patches unapplied)

Imported using git-ubuntu import.

1f65bf8... by Dimitri John Ledkov

0.137ubuntu8 (patches unapplied)

Imported using git-ubuntu import.

1ab0970... by Dimitri John Ledkov

0.137ubuntu7 (patches unapplied)

Imported using git-ubuntu import.

98abf31... by Gianfranco Costamagna

0.137ubuntu6 (patches unapplied)

Imported using git-ubuntu import.

8b13d3c... by Dimitri John Ledkov

0.137ubuntu5 (patches unapplied)

Imported using git-ubuntu import.

e61ba3c... by Gianfranco Costamagna

0.137ubuntu4 (patches unapplied)

Imported using git-ubuntu import.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/scripts/local-premount/resume b/scripts/local-premount/resume
2index 272a728..bc087b8 100755
3--- a/scripts/local-premount/resume
4+++ b/scripts/local-premount/resume
5@@ -19,6 +19,29 @@ if [ -z "${resume?}" ] || [ ! -e /sys/power/resume ]; then
6 exit 0
7 fi
8
9+wait_on_low_battery()
10+{
11+ while true; do
12+ supply_is_good=true
13+ for supply in /sys/class/power_supply/*; do
14+ [ -f "${supply}/status" ] || continue
15+ [ -f "${supply}/capacity" ] || continue
16+ grep -q Discharging "${supply}/status" || continue
17+ [ `cat ${supply}/capacity` -lt 5 ] || continue
18+ supply_is_good=false
19+ done
20+ if "$supply_is_good"; then
21+ break
22+ fi
23+ if [ "$use_plymouth" == "true" ]; then
24+ plymouth message --text="Battery Low. Please plug in to continue."
25+ else
26+ echo "Battery Low. Please plug in to continue."
27+ fi
28+ sleep 1
29+ done
30+}
31+
32 . /scripts/functions
33 . /scripts/local
34
35@@ -56,6 +79,8 @@ fi
36
37 case "${SWAPTYPE}" in
38 swsuspend|s1suspend|s2suspend|ulsuspend|tuxonice)
39+ wait_on_low_battery
40+
41 if "$use_plymouth"; then
42 plymouth message --text="Resuming from $resume"
43

Subscribers

People subscribed via source and target branches