I'm using Ubuntu 22.04 LTS and I want to know if there is a way to automatically switch to power saving mode when battery is below a specific percentage. I know there is the "Automatic Power Saver" option but how can I set it to change when below, let's say, 30%?
-
https://askubuntu.com/a/1311670/15811 only needs a check on the percentage. – Rinzwind Jul 07 '22 at 17:36
2 Answers
You can check every minute with cron if battery dropped below for e.g. 30% and run systemctl suspend
or change scaling_governor
to powersave.
Also, maybe simpler, using UPower.
To get related info:
cat /etc/UPower/UPower.conf | grep -v "^#" | egrep "Critical|Low|Action|Time"
gsettings list-recursively org.gnome.settings-daemon.plugins.power
To get suspend/hibernate support, use pm-is-supported
from pm-utils package.

- 15,657
At first turn on Automatic Power Saver Turn on Automatic Power Saver Option Then open terminal and run this command and it will give the current settings for auto power saving mode.
cat /etc/UPower/UPower.conf | grep -v "^#" | egrep "Critical|Low|Action|Time"
Out put Should like below (consider the highlighted one i.e. PercentageLow=):
PercentageLow=20
PercentageCritical=5
PercentageAction=2
TimeLow=1200
TimeCritical=300
TimeAction=120
CriticalPowerAction=HybridSleep
Now edit "/etc/UPower/UPower.conf" to reflect the desired values(i.e. you have to change "PercentageLow=20" as "PercentageLow=30"(e.g. the change value indicates that auto power saving mode will turn on when battery has 30% left))
processing to edit this file
This required root priviledge
sudo nano /etc/UPower/UPower.conf
- Now find the line "PercentageLow=20" and edit it with the desired value in which point you want to auto power saving mode turn on(e.g.PercentageLow=20 for at 20% or PercentageLow=30 for at 30%)
- After editing
- Press CTRL+O
- Press ENTER
- Press CTRL+X
- Reboot or Restart your system.
Now your system will automatically turn on Power Saving Mode.

- 2,426