62

I would like my laptop to hibernate itself when the battery level is 10% to be sure it has enough power to complete the operation properly. Actually if I don't pay attention my laptop informs me it will hibernate when it's too late, so instead it brutally shuts down. This kills lithium batteries and is not acceptable.

  • The approved answer above does not work on Ubuntu 12.04. – user1956808 Jun 25 '16 at 21:03
  • 1
    what works is hackerb9's answer. Tested on ubuntu 16.04 – user47206 Sep 16 '16 at 7:40
58
  1. Start dconf-editor
  2. Browse to org -> gnome -> settings-daemon -> plugins -> power
  3. Change the values of percentage-critical and percentage-action to the level you require
  4. Change use-time-for-policy to false
  5. Done!

You can also do this from a terminal with:

gsettings set org.gnome.settings-daemon.plugins.power percentage-critical 10
gsettings set org.gnome.settings-daemon.plugins.power percentage-action 9
gsettings set org.gnome.settings-daemon.plugins.power use-time-for-policy false
  • 2
    Thanks. Ubuntu will not cost me 100s of dollars now FFS. – Salman Abbas Jul 26 '13 at 12:26
  • Tried this and having problem If you know how to solve this please let us know – Waqas Mar 7 '14 at 14:10
  • not luck on 15.04 64bit, 3.19.0-32, thinkpad t440p – enjoy Nov 17 '15 at 11:15
  • 2
    How to do it for 16.04 ? – Anmol Singh Jaggi Jun 10 '16 at 21:35
  • 1
    @cipricus Yes! Its working. – Anmol Singh Jaggi Sep 15 '16 at 20:58
27
+50

Looks like Gnome moved the settings. Critically low battery is now handled by UPower. Instead of using gsettings, you should now edit the file /etc/UPower/UPower.conf

UsePercentageForPolicy=true
PercentageLow=10
PercentageCritical=3
PercentageAction=2
CriticalPowerAction=HybridSleep

By the way, if you read the UPower.conf file, upower used to (in v 0.99.1) only suggest using percentages in order to work around broken firmware. The default was UsePercentageForPolicy=false, which used the battery's time estimate. That makes some sense since, as a battery gets older, it lasts shorter for any given percentage. A fixed percentage that worked previously might at some point no longer allow the laptop enough time to hibernate properly.

However, it looks like upower now (v 0.99.4) is defaulting to percentages and has a cryptic message about the reasoning. I don't know which is best, but here's how to use time remaining for your battery policy, if you so desire.

UsePercentageForPolicy=false
TimeLow=1200
TimeCritical=300
TimeAction=120
CriticalPowerAction=HybridSleep

Note that Suspend/Sleep as such is not supported by the Upower tool, that HybridSleep is used instead (which looks much like Sleep, but is also close to Hibernation) and that HybridSleep (just like Hibernation) needs a swap space to work. On how to create one in case you don't have it, see this answer.

  • The bounty I set will be granted to this answer. – user47206 Sep 14 '16 at 12:14
  • @hackerb9 do we need to restart the machine in order for the change to take effects – Kasun Siyambalapitiya Jul 3 '18 at 9:19
  • You can do sudo systemctl restart upower.service to apply the settings. – Florian Feb 27 at 18:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.