Just as the OP asked in the other question, I would like to have a battery threshold.
However, for me, when I type into the terminal
echo 80 | sudo tee /sys/class/power_supply/BAT0/charge_control_end_threshold
I get a message in the terminal saying "Permission denied", even when I type "sudo" before "echo".
How can I still do it?
EDIT: I use Ubuntu 20.04 on a Dell Latitude 7390.
That's why I get in the terminal when I go to /sys/class/power_supply/
When I go into the folder BAT0
, this is what I get:
Edit:
This is what I get when running smbios-battery-ctl --set-charging-mode custom
.
Please read through the entire post. I am giving two possible solutions, plus one possible solution route (to be explored further if needed).
Solution 1
This thread mentions application
cctk
(Client Configuration Toolkit) specific for Dell.Command
cctk --PrimaryBattChargeCfg=Custom:50-70
might work.CCTK was likely superseded by Dell Command | Configure, I am not sure if CCTK still works in some systems.
Solution 2
This thread refers to interaction between TLP and Dell. But official documentation shows battery thresholds for Dell cannot be controlled with TLP. At the bottom of the thread, it is shown that libsmbios could help, via
smbios-battery-ctl --set-custom-charge-interval low high
(with
smbios-battery-ctl --set-charging-mode custom
).Another possible route
In my Lenovo, I have
charge_start_threshold
andcharge_stop_threshold
, notcharge_control_start_threshold
andcharge_control_end_threshold
. in/sys/class/power_supply/BAT0
.This old answer shows files
start_charge_thresh
andstop_charge_thresh
in directory/sys/devices/platform/smapi/BAT0/
for a Lenovo.So chances are the file names and/or directory should be different in your Dell. You might try all the same but with file names as
charge_end_threshold
,charge_stop_threshold
,charge_control_stop_threshold
instead, and follow up on the OP you linked.Extra info
This old thread mentions that if you set the thresholds in Windows, Linux will abide by them, although there is no way to change them from within Linux. I don't know if this workaround is useful for you, and the info is possibly outdated anyway.
This mentions that
For maximum lifespan when rarely using the battery, set Custom charge thresholds to start charging at 40% capacity and stop at 50%, and keep the ThinkPad cool. The thresholds can be adjusted in the Battery Maintenance settings of Lenovo Power Manager.
If the battery is used somewhat frequently, set the start threshold at around 85% and stop at 90%. This will still give a good lifespan benefit over keeping the battery charged to 100%.
Download Dell Command Configure for Ubuntu 20.04 from here. Download link.
Install according to this article
Enter the installed directory.
cd /opt/dell/dcc
Run
sudo ./cctk --PrimaryBattChargeCfg=Custom:low-high
(example:sudo ./cctk --PrimaryBattChargeCfg=Custom:50-70
Documentation on options
With the help of a bunch of extra data and the Dell Latitude 7390 Owner's Manual, it looks like the BIOS is not configured to allow your battery to make use of some Advanced Power Management features such as
charge_control_end_threshold
andcharge_stop_threshold
.The first clue was from the
Permission denied
error when settingcharge_control_end_threshold
, as we cannot add anything to/sys/class/
that does not already exist. When this same error appeared forcharge_stop_threshold
, it forced a rethink to determine whether the battery was calledBAT0
,BATT
, orBATC
(orBAT1
on a couple of Acer models). However, the final confirmation is seen with the output of the/sys/class/power_supply/BAT0/
pseudo-directory. These "files" are API interfaces when working with the battery, which is why we cannot add (or remove) any of them.Unfortunately I do not have a Dell nearby to test this with but, according to the owner's manual, it may be possible to activate the features needed by tweaking a couple of settings in the BIOS.
Let's try this:
Reboot the machine
Enter the BIOS
⇢ Press F12 key when the Dell logo appears to access a boot menu with a list of the valid devices. Choose "Other Options" then enter "BIOS Setup"
Find "Power Management"
Find "Primary Battery Charge Configuration" and change the value to "Custom". As per the documentation:
Save the settings and boot back into Ubuntu
With this done, so long as your battery supports the ability to set (and display) charge thresholds, you should see
charge_control_end_threshold
and/orcharge_stop_threshold
in the/sys/class/power_supply/BAT0
location.Hope this gives you what you're looking for ??