I have found a (dirty?) workaround for this. The idea is simple: use a
udev rule to suspend the laptop before UPower shuts it down. This can be
done by creating a file /etc/udev/rules.d/99-lowbat.rules with the
following content:

# Suspend the system when battery level drops to 5% or lower
SUBSYSTEM=="power_supply", ATTR{status}=="Discharging", 
ATTR{capacity}=="[0-5]", RUN+="/usr/bin/systemctl suspend"

You can of course tune the threshold.

This method seems to work well for me. If you want to use a threshold
that's lower than the UPower one, *I think* you could set the
PercentageAction parameter to 0% or 1% in /etc/UPower/UPower.conf,
although I'm not 100% sure this is a good idea (the disclaimer at the
beginning of the file seems to discourage users from directly modifying
the file).


Reference: 
https://wiki.archlinux.org/title/laptop#Hibernate_on_low_battery_level


On a side note, I definitely wish this bug could be addressed. It's not normal 
that a computer just shuts down and makes you lose your work when there's still 
battery. Also note that afaik there's currently no way to enable hibernation 
with full disk encryption, so this limitation of UPower will become 
increasingly serious as more and more users will make the (right) choice to use 
FDE.

-- 
You received this bug notification because you are a member of Ubuntu
Touch seeded packages, which is subscribed to upower in Ubuntu.
https://bugs.launchpad.net/bugs/1852911

Title:
  CriticalPowerAction=Suspend should be supported

Status in Upower:
  New
Status in upower package in Ubuntu:
  Triaged

Bug description:
  The action to take when the battery is critical can only be one of the
  following:

  # Possible values are:
  # PowerOff
  # Hibernate
  # HybridSleep

  Adding Suspend to that list makes perfect sense. My laptop is
  currently powering off on low power which is useless as I'll be losing
  my work anyway. Might as well suspend and allow me to notice that and
  connect a charger. If the thinking is that suspend uses power I can
  set a high enough threshold to give me some margin.

  The failovers are:

  # If HybridSleep isn't available, Hibernate will be used
  # If Hibernate isn't available, PowerOff will be used

  I'd argue Suspend should actually come before PowerOff in that list.
  For most laptop users having their computer suspend because they
  didn't notice the battery was running out is very easy to fix and
  takes no time. They'll just connect the charger. If however the
  computer needs to be completely rebooted, not only does that take a
  lot more time it will very likely cause lost work.

  ProblemType: Bug
  DistroRelease: Ubuntu 19.04
  Package: upower 0.99.10-1
  ProcVersionSignature: Ubuntu 5.0.0-32.34-generic 5.0.21
  Uname: Linux 5.0.0-32-generic x86_64
  ApportVersion: 2.20.10-0ubuntu27.3
  Architecture: amd64
  CurrentDesktop: Unity
  Date: Sun Nov 17 14:32:13 2019
  InstallationDate: Installed on 2019-05-09 (191 days ago)
  InstallationMedia: Ubuntu 19.04 "Disco Dingo" - Release amd64 (20190416)
  SourcePackage: upower
  UpgradeStatus: No upgrade log present (probably fresh install)

To manage notifications about this bug go to:
https://bugs.launchpad.net/upower/+bug/1852911/+subscriptions


-- 
Mailing list: https://launchpad.net/~touch-packages
Post to     : touch-packages@lists.launchpad.net
Unsubscribe : https://launchpad.net/~touch-packages
More help   : https://help.launchpad.net/ListHelp

Reply via email to