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– user19568082016-06-25 21:03:39 +00:00Commented Jun 25, 2016 at 21:03
-
2what works is hackerb9's answer. Tested on ubuntu 16.04user47206– user472062016-09-16 07:40:47 +00:00Commented Sep 16, 2016 at 7:40
2 Answers
- Start
dconf-editor - Browse to
org->gnome->settings-daemon->plugins->power - Change the values of
percentage-criticalandpercentage-actionto the level you require - Change
use-time-for-policytofalse - 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
-
3Thanks. Ubuntu will not cost me 100s of dollars now FFS.Celmaun– Celmaun2013-07-26 12:26:18 +00:00Commented Jul 26, 2013 at 12:26
-
-
2How to do it for 16.04 ?Anmol Singh Jaggi– Anmol Singh Jaggi2016-06-10 21:35:39 +00:00Commented Jun 10, 2016 at 21:35
-
1@AnmolSinghJaggi - have you noticed the other answer?user47206– user472062016-09-14 09:44:41 +00:00Commented Sep 14, 2016 at 9:44
-
1this doesn't work on ubuntu 20.04 to get a pop-up notification when the battery level gets low. But hackerb9's solution below works!NeStack– NeStack2021-05-20 22:27:34 +00:00Commented May 20, 2021 at 22:27
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.
-
5You can do
sudo systemctl restart upower.serviceto apply the settings.Florian– Florian2019-02-27 18:31:42 +00:00Commented Feb 27, 2019 at 18:31 -
1the upower.conf mentions warning, and "upower -d" at CLI one of the items listed is "warning-level" and by default its value is "none". I would like very much to get some kind of warning before the notebook does a shutdown. Is the upower.conf options documented somewhere that might show how to set a warning level?alabamatoy– alabamatoy2020-01-14 19:08:12 +00:00Commented Jan 14, 2020 at 19:08
-
1@alabamatoy did you have any luck with getting a warning?lucidbrot– lucidbrot2020-12-24 00:29:39 +00:00Commented Dec 24, 2020 at 0:29
-
1I find it "interesting" that Upower.conf starts with such a comment: # Only the system vendor should modify this file, ordinary users should not have to change anything.Levente– Levente2020-12-26 15:12:37 +00:00Commented Dec 26, 2020 at 15:12
-
1In Ubuntu 20.04, it appears the default is now
UsePercentageForPolicy=true(unless another program modified my config since the initial OS install)Addison Klinke– Addison Klinke2021-12-15 15:53:42 +00:00Commented Dec 15, 2021 at 15:53