[KDE] Battery charge limit reset after reboot

Using battery charge limiter from KDE settings and it works, but it reset every time i shutdown the laptop (MBA M1 2020).
There is a way to make it persistent across reboot?

1 Like

You can use this command: echo 'SUBSYSTEM=="power_supply", KERNEL=="macsmc-battery", ATTR{charge_control_end_threshold}="80"' | sudo tee /etc/udev/rules.d/10-battery.rules

This will persist across reboots, and will work on all Desktop Environments.

I wonder if there is a way to set it in firmware, so that it doesn’t get forgotten when you power off. Right now, if you are connected to AC and poweroff (or even sleep), the battery get charged to 100%. IIRC, this doesn’t happen when macOS limits battery charging.

This is not correct. The level is a firmware flag, it absolutely keeps working in sleep mode (that’s the whole reason why we changed the implementation to this, from the old software emulation that was more flexible but didn’t), and last time I tried it I’m pretty sure it also worked if you did a clean shutdown (you can tell on MagSafe machines because the Magsafe LED never goes green).

It does definitely get reset to 100% on boot and there is no way to fix that, since SMC gets rebooted on every boot and there is no persistent storage involved as far as I know. So if you end up rebooting and forcing a shutdown before Linux boots or anything like that, yeah, then it’ll get reset.

Edit: I’m shutting down my M1 Pro overnight, just to confirm. Let’s see what the charge level is in the morning.

Hmm… thanks for the explanation.

You are correct, I was wrong about the sleep mode surely. It was a mistake. But I’m pretty sure it did happen for me with power off before. But I’ve not tested it in at least a month since I’ve started to make sure AC is not connected when powered off.

Interestingly, it did charge to 100% this time. But I’m pretty sure I’ve seen it not do that at least once, so now I wonder if there’s some variable we’re missing here or I just got confused.

Either way, whatever behavior we have here should be the same as macOS gets. It doesn’t do anything special as far as I know, the SMC firmware design is what it is.

Oh, I was hoping that you’ll get a different result. I’ll try to test with macOS again soon, but I “feel” it didn’t charge to 100% there. Anyway, thanks for your test. I was wondering if there is something wrong with me :">