3

I have tried to change the low and critical battery thresholds but the OS still does not seem to recognize that.

What I have tried:

  1. Changing /etc/UPower/UPower.conf to:
    UsePercentageForPolicy=true
    PercentageLow=30
    PercentageCritical=20
    PercentageAction=20
    CriticalPowerAction=HybridSleep

The file maintains the modifications but still the laptop notifies me of low battery at the default 10%

  1. Changing the same values with dconf-editor in org -> gnome -> settings-daemon -> plugins -> power

Still the laptop notifies me when the battery reaches 10% instead of 30%.

  1. using the command line, like: gsettings set org.gnome.settings-daemon.plugins.power percentage-low 30

The the laptop continues to behave as if there's no change. I have been trying to solve this problem for weeks but I couldn't find a way. I searched a lot on the internet but couldn't find anything that could solve this issue. Any help would be greatly appreciated.

EDIT 1:

Thank you sancho.s for your great suggestions. I did set the use-time-for-policy value to false already. I double checked and it seems that is indeed false.

Your temporary workaround unfortunately doesn't seem to work. I calculated the ratio you mentioned and I had it at 5%. I changed it to 30% by modifying alarm to a number 6x higher. Nothing seems to happen when the battery reaches 30%.

The related links were indeed useful but I already read those answers previously, and tried the suggestions in them, which I also reported in my original question. Unfortunately I couldn't solve the problem.

The version of my Ubuntu is 20.04 LTS, and it's running on a Thinkpad X1. I should point out that I formatted my laptop a few weeks ago, and before formatting, UPower was working correctly on 20.10. Afterwards I changed in the BIOS settings the AHCI to RST but I reverted all the changes before formatting and installing 20.04 LTS. I thought this might be related, but I reverted all the changes and I wouldn't know what to check to make sure there isn't a problem there.

2 Answers2

1

I did not identify anything wrong with what you did. Even so, try gsettings set org.gnome.settings-daemon.plugins.power use-time-for-policy false, and rebooting. Or sudo systemctl restart upower.service should preform the same as rebooting.

As a workaround, there are two relevant files in /sys/class/power_supply/BAT0 (this location may change depending on the computer, you can easily find it with locate BAT0 assuming your is BAT0). Check the values in energy_full (the same as in variable POWER_SUPPLY_ENERGY_FULL of file uevent) and in alarm. The ratio gives you the percentage for an alarm, in my case alarm/energy_full=5%. You can set it to 10% by calculating target=10%*energy_full, and using that number in echo <target> | sudo tee /sys/class/power_supply/BAT0/alarm. YMMV.

In the meantime, please post the brand/model of your computer and Ubuntu version.

Related:

  1. How to change critically low battery value?
  2. Laptop not shutting down on low power
  3. Difference between dconf power settings and Upower.conf?

Related to .../BAT0/...:

  1. https://www.reddit.com/r/Ubuntu/comments/9l5nkv/need_solution_to_handle_low_battery_protocol_with/
  2. https://unix.stackexchange.com/questions/84437/how-do-i-make-my-laptop-sleep-when-it-reaches-some-low-battery-threshold
  3. https://linrunner.de/tlp/index.html
1

All the percentage values need to be descending (PercentageLow>PercentageCritical>PercentageAction), otherwise the defaults will be loaded for all values. This condition is not met in your configuration, where PercentageCritical=PercentageAction. I checked the source code of upower and the condition is really defined this way in src/up-daemon.c.