How to set automatic battery threshold to 49% - 50%?

Hi, I’m novice and I’ve been trying to follow the steps from this thread to set battery thresholds but am having some issues (Fedora 41 XFCE is my base template).

#1. How can I overcome the permission issue?
echo '50' | sudo tee sys/class/power_supply/BAT1/charge_control_end_threshold: Permission denied 50

#2. No charge_control_end_threshold file present; what do I do in this case?
I noticed that my sys/class/power_supply/ folder only has a BAT1 folder, but no BAT0. The BAT1 folder doesn’t have a charge_control_end_threshold file. Below is a screen capture of its contents. Am I supposed to create a text file in this folder and rename it to charge_control_end_threshold and charge_control_start_threshold or use one of the existing files? How would I accomplish this?

#3. How can I set the charge thresholds to be enforced automatically upon reboot?

Any help is much appreciated! :pray:

1 Like

I’ve done it before in xfce and it works but I currently use kde because there is a dedicated setting for it in power settings. My recollection is that once you change the % threshold it persists across restarts unless you unplug the battery.

For #2 you would use the touch command to create an empty file with that name and then use the command to change the %. I think I just went into the relevant folder and opened text editor (geany or mousepad or nano) and added the % I wanted. If you open nano with a filename that doesn’t exist it will create it (thus solving your issue)

1 Like

Alright, while I figure out the permission issue, I installed KDE following the Qubes OS guide, it seems like the sudo qubes-dom0-update kde-settings-qubes was successful, but I don’t see the Power Management > Advanced Power Settings option Q > Gear > System Settings > Power Management. How would I change the charge limit after installing KDE?

1 Like

When you login (the second time you enter password after startup) you need to choose kde from upper right drop down, you want the x11 option NOT plasma. Then when you go into power settings there are upper and lower thresholds for battery charging.

2 Likes

I’m afraid your laptop subsystem does not allow to set a threshold.

3 Likes

Interesting, I didn’t realize that was possible. Can you point me to any info on why a laptop wouldn’t support this or what hardware feature allows for it ?

1 Like

I don’t have any material sorry, but for this feature the laptop must have a bypass to let power go from the outlet to the computer without going through the battery, it is not a software solution.

2 Likes

I’m trying to find a solution to this as well on a laptop that does not support thresholds. I tried installing TLP on a Fedora LiveUSB and sadly that did not add support. I tried a few different kernels as well.

Anyone know if there’s a command to toggle charging? A lightweight cron job in dom0 seems doable, I just can’t find any clear answers on triggering events from shell.

1 Like

You can’t circumvent the lack of this hardware feature with a software solution. There is no way to change how the electric wiring is done unfortunately.

You could remove the battery if you use the laptop a long time plugged in, but I admit it’s not practical depending on the frame, but this is what I’ve been doing for a decade before laptops started supporting thresholds.

2 Likes

I was just coming back to edit my post… thanks @solene

I believe my specific device’s firmware does support it as per docs, so… lemme try debian next and report back. Might be a simple driver issue.

1 Like

In my case I got the source code from the vendor and needed to build/install the driver via DKMS.

@Droplet6200 what laptop are you using?

1 Like

I was using a Lenovo ThinkPad T440p but am moving onto a Lenovo IdeaPad Gaming 3 15ARH7 (82SB). It seems the Thinkpad T440p does support charging thresholds although mine is running Skulls, a fork of Coreboot, so I’m not sure how that might affect it. The Lenovo IdeaPad Gaming 3 15ARH7 is running the stock BIOS although I couldn’t find details on whether it supports charging thresholds.

1 Like

Doesn’t removing the battery increase the risk of electrical damage to the other components? Mine is plugged into a UPS. Not sure if this makes it safe enough to keep it without a battery.

1 Like

No it does not, but your laptop becomes vulnerable to brownouts and/or blackouts.

1 Like