π Automating Battery Charge Limits on Arch Linux (KDE Plasma)
- Jean-Christophe Miler
- Linux
- December 19, 2025
Table of Contents
If you use a laptop with Linux, you probably know that keeping your battery at 100% while plugged into AC power all day is a recipe for premature battery degradation. Most modern laptops support a “Battery Threshold” or “Conservation Mode,” usually capped at 80%.
However, sometimes the native KDE Plasma settings (powerdevil) simply refuse to apply these limits to the hardware. In this guide, we will bypass the GUI and use Systemd Units to force a charge limit of 80% every time you plug in your charger.
The Problem
In KDE Plasma, you might see a setting for “Charge Limit” in the Power Management menu. Under the hood, this writes to powerdevilrc. But if your kernel doesn’t communicate perfectly with Plasma, that setting remains a suggestion rather than a rule.
We want a robust, system-level solution that:
Detects when the AC Adapter is plugged in.
Immediately writes the 80% limit to the kernel’s
sysfsinterface.Operates with root privileges automatically.
Step 1: Discover Your Hardware Names
Linux maps hardware to files in /sys/class/power_supply/. These names vary by manufacturer (e.g., Lenovo, Dell, ASUS).
Run this command:
ls /sys/class/power_supply/
Take note of the results:
The AC Adapter: Usually named
AC,ACAD,ADP1, orAC0.The Battery: Usually named
BAT0orBAT1.
For this guide, we will assume your AC adapter is ACAD and your battery is BAT1. Replace these in the scripts below with your actual names.
Step 2: Create the Systemd Service
This service performs the actual work of writing the “80” value to the battery’s threshold file.
Create the file:
sudo nano /etc/systemd/system/battery-limit-ac.service
Paste the following:
[Unit]
Description=Set Battery Charge Limit to 80%% on AC Power
After=multi-user.target
[Service]
Type=oneshot
# Ensure the battery threshold file exists before running
ConditionPathExists=/sys/class/power_supply/BAT1/charge_control_end_threshold
# 1. Check if AC is actually online (1 = plugged in)
ExecStartPre=/bin/bash -c 'grep -q "1" /sys/class/power_supply/ACAD/online'
# 2. If plugged in, set the limit to 80
ExecStart=/bin/sh -c 'echo "80" > /sys/class/power_supply/BAT1/charge_control_end_threshold'
[Install]
WantedBy=multi-user.target
Step 3: Create the Systemd Path Unit
A “Service” runs once. A “Path Unit” monitors a file for changes. We want to monitor the online status of your AC adapter so the service triggers every time you plug it in.
Create the file:
sudo nano /etc/systemd/system/battery-limit-ac.path
Paste the following:
[Unit]
Description=Monitor AC Power Status to Trigger Battery Limit
[Path]
# Monitor the AC status file for changes (plugging/unplugging)
PathModified=/sys/class/power_supply/ACAD/online
[Install]
WantedBy=multi-user.target
Step 4: Enable and Test
Now, tell the system to start watching for those power events.
# Reload systemd to see the new files
sudo systemctl daemon-reload
# Enable the path unit (this stays active in the background)
sudo systemctl enable --now battery-limit-ac.path
# Manually start the service once to verify it works right now
sudo systemctl start battery-limit-ac.service
Verification
To confirm the limit is active, check the value directly from the kernel:
cat /sys/class/power_supply/BAT1/charge_control_end_threshold
If it returns 80, you are successful!
Troubleshooting
Permission Denied: If you try to run the
echocommand manually as a user, it will fail. This is why we use Systemdβit executes the command asroot.File Not Found: If
charge_control_end_thresholddoesn’t exist, your laptop may use a different name likecharge_stop_threshold. Checkls /sys/class/power_supply/BAT1/to see available files.AC Name: If the service fails with “No such file” for the AC adapter, double-check Step 1. Your charger might be named
AC0orADP1instead ofACAD.
Conclusion
By using a Systemd Path unit instead of a standard KDE script, we’ve created a “set and forget” solution. Your battery will now stop charging at 80% every time you plug it in, significantly extending its lifespan.
