Controlling battery charge

Hat

New Member
Joined
Oct 28, 2025
Messages
1
I am running Xubuntu on a old Lenovo B50. It all works well, but have not managed to find yet how to limit the battery charge at about 80%, as it was possible with the Lenovo software originally installed on Windows. Do you have any idea on how to proceed? Doing it manually is distracting.

thank you
 

Solution
Yes — you can do this on Linux, but the exact method depends on what your B50 exposes to the kernel. Here are short diagnostics + three safe ways to set an automatic ~80% stop threshold (sysfs when available, TLP when supported, and fallback using acpi_call). Follow the checks and then try the method that matches what you find.
Step 0 — quick info I need if you want me to tailor instructions
Please paste the output of these (or run them and tell me what they show):
  • ls /sys/class/power_supply/
  • grep -i charge /sys/class/power_supply/* -R 2>/dev/null || true
  • uname -a
  • sudo dmidecode -s system-product-name (or just tell me the exact model string printed on the laptop label)
Step 1 — check what your kernel exposes (the...
Yes — you can do this on Linux, but the exact method depends on what your B50 exposes to the kernel. Here are short diagnostics + three safe ways to set an automatic ~80% stop threshold (sysfs when available, TLP when supported, and fallback using acpi_call). Follow the checks and then try the method that matches what you find.
Step 0 — quick info I need if you want me to tailor instructions
Please paste the output of these (or run them and tell me what they show):
  • ls /sys/class/power_supply/
  • grep -i charge /sys/class/power_supply/* -R 2>/dev/null || true
  • uname -a
  • sudo dmidecode -s system-product-name (or just tell me the exact model string printed on the laptop label)
Step 1 — check what your kernel exposes (the easiest, safest way)
Run these commands:
  • ls /sys/class/power_supply/
  • for d in /sys/class/power_supply/*; do echo "---- $d"; ls -1 "$d"; done
Look for files named like any of:
  • charge_control_start_threshold
  • charge_control_end_threshold
  • stop_charge_threshold
  • start_charge_threshold
    If you find them, you can set thresholds directly.
How to set the threshold immediately (if those files exist)
Example (change BAT0 if your battery folder is different):
  • sudo sh -c 'echo 80 > /sys/class/power_supply/BAT0/charge_control_end_threshold'
  • sudo sh -c 'echo 75 > /sys/class/power_supply/BAT0/charge_control_start_threshold'
Verify:
  • cat /sys/class/power_supply/BAT0/charge_control_end_threshold
Make persistent across reboots (systemd service)
Create /etc/systemd/system/battery-threshold.service with content:
[Unit]
Description=Set battery charge thresholds
After=multi-user.target
[Service]
Type=oneshot
ExecStart=/bin/sh -c "echo 75 > /sys/class/power_supply/BAT0/charge_control_start_threshold || true; echo 80 > /sys/class/power_supply/BAT0/charge_control_end_threshold || true"
[Install]
WantedBy=multi-user.target
Then:
  • sudo systemctl daemon-reload
  • sudo systemctl enable --now battery-threshold.service
Notes: adjust BAT0 and numbers as you like. If writing fails, the files are not writable/available and you’ll get an error — move to the TLP/acpi_call methods below.
Step 2 — use TLP (recommended if sysfs is not present and your model is supported)
TLP is the standard power tool for laptops on Ubuntu/Xubuntu.
Install:
  • sudo apt update
  • sudo apt install tlp tlp-rdw
Edit /etc/tlp.conf: find and set (uncomment) lines:
  • START_CHARGE_THRESH_BAT0=75
  • STOP_CHARGE_THRESH_BAT0=80
Then start/restart TLP:
  • sudo tlp start
Check support:
  • sudo tlp-stat -b
    This output shows whether TLP can control thresholds on your machine and which kernel interfaces it will use (tp_smapi, acpi_call, ideapad_laptop, etc.. If tlp-stat indicates it cannot control the battery, move to the acpi_call fallback.
Step 3 — fallback: acpi_call (advanced, but works on many Lenovo/IdeaPad models)
Some laptops do not expose sysfs but can be controlled by writing ACPI calls. This is more model-specific and has a small risk of making ACPI calls that don’t apply — proceed only if you’re comfortable.
Install:
There are scripts and projects (and TLP can be configured to use acpi_call) that attempt the right ACPI method for your model. If you want, share tlp-stat -b and the outputs from Step 0 and I can suggest the exact acpi_call steps for your B50.
Important notes and caveats
  • Not all Lenovo models expose thresholds in Linux. Older/cheap models sometimes don’t.
  • Writing thresholds requires root and the kernel driver/ACPI method to support your hardware.
  • Some BIOS/firmware can override or reset thresholds on a reboot/AC change.
  • Always test with conservative values first (start 75 / stop 80).
  • To undo: remove the systemd service and reset values to 100 (or stop TLP threshold handling).
If you want, I can:
  • walk you step-by-step through whichever method looks available on your machine, or
  • analyze the exact outputs if you paste the results of the Step 0 commands I asked for.
Which would you like to try first?
 

Solution
Back
Top