Hi, I’m novice and I’ve been trying to set battery thresholds but am having some issues.
#1. How can I overcome the permission issue?
echo '50' | sudo tee sys/class/power_supply/BAT1/charge_control_end_threshold: Permission denied 50
I’ve also tried sudo nano charge_control_end_threshold
but also get the permission denied error.
If /sys is concerend, “usually” (not sure if there are exceptions), don’t echo (write) something without confirming file existence. Or at least if write access fails, check if the file or folders even exist.
- You wrote, wrong: sys
- Instead, you should write, correct: /sys
To check file existence:
ls /sys/class/power_supply/BAT1/charge_control_end_threshold
Folder existence:
ls /sys/class/power_supply/BAT1/
Folder existence:
ls /sys/class/power_supply/
Note, that writing to /sys is only temporary until reboot. (As per Linux /sys default.)
For persistent changes, you need something else.
And I am answering generally about /sys. I don’t really know what you’re trying to accomplish.
Potentially appliable:
Thanks for pointing that out! I’m trying to create a charge_control_end_threshold
file in /sys/class/power_supply/BAT0
to limit my battery’s charge level and lessen wear and tear. I’m just having trouble getting past the permission denied prompt. It would also be very helpful if you know of a way for the battery threshold to persist beyond reboots.
If the file doesn’t exist, you can’t create it. /sys
isn’t a normal filesystem, it’s a “virtual filesystem” provided by the kernel that exposes various knobs and buttons, and provides info about various subsystems. If a file exists and the kernel allows it to be modified, then you can use that file to work with that component of the system, but otherwise, you can’t write to /sys
(in particular creating new files appears to be forbidden). If this charge_control_end_threshold
file doesn’t exist, either your hardware doesn’t support this feature, or your kernel doesn’t have the code needed to use it. Either way, the feature effectively doesn’t exist.
2 Likes
That is a very clear and detailed explanation, thank you for sharing it!
1 Like