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
diff --git a/scripts/local-premount/resume b/scripts/local-premount/resume
index 272a728..bc087b8 100755
--- a/scripts/local-premount/resume
+++ b/scripts/local-premount/resume
@@ -19,6 +19,29 @@ if [ -z "${resume?}" ] || [ ! -e /sys/power/resume ]; then
19 exit 019 exit 0
20fi20fi
2121
22wait_on_low_battery()
23{
24 while true; do
25 supply_is_good=true
26 for supply in /sys/class/power_supply/*; do
27 [ -f "${supply}/status" ] || continue
28 [ -f "${supply}/capacity" ] || continue
29 grep -q Discharging "${supply}/status" || continue
30 [ `cat ${supply}/capacity` -lt 5 ] || continue
31 supply_is_good=false
32 done
33 if "$supply_is_good"; then
34 break
35 fi
36 if [ "$use_plymouth" == "true" ]; then
37 plymouth message --text="Battery Low. Please plug in to continue."
38 else
39 echo "Battery Low. Please plug in to continue."
40 fi
41 sleep 1
42 done
43}
44
22. /scripts/functions45. /scripts/functions
23. /scripts/local46. /scripts/local
2447
@@ -56,6 +79,8 @@ fi
5679
57case "${SWAPTYPE}" in80case "${SWAPTYPE}" in
58 swsuspend|s1suspend|s2suspend|ulsuspend|tuxonice)81 swsuspend|s1suspend|s2suspend|ulsuspend|tuxonice)
82 wait_on_low_battery
83
59 if "$use_plymouth"; then84 if "$use_plymouth"; then
60 plymouth message --text="Resuming from $resume"85 plymouth message --text="Resuming from $resume"
6186

Subscribers

People subscribed via source and target branches