Make battery discharge while connected to AC (charging thresholds)

I found a solution for setting up charging thresholds in dom0 without installing anything there, here, which is

echo '85' | sudo tee /sys/class/power_supply/BAT0/charge_control_end_threshold
echo '75' | sudo tee  /sys/class/power_supply/BAT0/charge_control_start_threshold

I set that to 40 for start threshold and to 80 for end threshold.
Question: Do you know how to make battery discharge after it reaches the limit I set for battery to stop charging while connected to the AC? Ex. it reaches 80% and then discharge to 40% and start charging once again and all that while connected to the AC? Maybe something to edit in charge_behaviour in /sys/class/power_supply? Also when it reaches 80%, when I click battery icon, it says Waiting for discharge but it’s not discharging.

If you charge the battery up to the end threshold 80%, disconnect the AC, use the laptop for some time to discharge to e.g. 75%, connect the AC back then will it start charging up to end threshold 80% again or not?

No, it won’t. It says Waiting to discharge, too.

That’s expected behavior then.
If you’re wondering why your battery charge level stayed at 80% when fully charged - it’s because the battery self-discharge is very slow and battery charge level could be reduced to 79% only after a few days.

Hi, I’d like to implement this charging threshold but cannot find how to type “|”. Since text cannot be easily pasted into the dom0 terminal, I’m having trouble getting these commands entered. I have a few questions,

  • How did you type this symbol?
  • What is this symbol called?
  • Is this symbol necessary for the command to function properly?
  • Does this charge threshold only take effect when Qubes OS is on or does it also take effect if the computer is asleep, turned off, or even running a different OS?

This symbol is called a “pipe”, and is one of the most frequently used symbols in Linux.

Very much so.

On the standard US keyboard, it is SHIFT + \

On other countries’ keyboards, it is usually the same key. If you can find the backslash (\), it will usually be the same key.

2 Likes