Variation on the theme above for those that may want to use bios and the framework_tool for battery charge control. Note that using the framework_tool requires having kernel 6.12 or higher.
This and other topics caution against using the bios charge control feature and/or the framework_tool when using /sys/class/power_supply/BAT1/charge_control_end_threshold
to control the battery charge limit.
While I think using the cros_charge_control
kernel module parameter charge_control_end_threshold
and the systemd unit described above is (more) straight forward, I prefer to use the bios and the framework_tool.
The recent beta bios updates (for both intel e.g. here and ryzen e.g. here) that include the new “automatic battery lifetime extender” feature further push me to use the framework_tool (i.e. is this new bios feature also incompatible with the charge_control_end_threshold
parameter method?).
A bash function included in ~/.bashrc and a systemd unit:
batcc() {
# installation:
# cd ${HOME}
# git clone https://github.com/FrameworkComputer/framework-system.git
# cd framework-system
# cargo clean
# cargo clippy
# cargo fmt --check
# cargo fmt
# cargo build
# sudo cp target/debug/framework_tool /usr/local/bin
# sudo cp ${HOME}/batcc@.service /etc/systemd/system/
# sudo systemctl daemon-reload
# sudo systemctl enable batcc@60
# sudo systemctl start batcc@60
# sudo systemctl status batcc@60
# sudo journalctl -xeu batcc@60.service
lower_limit=40
upper_limit=100
batcc_status="/usr/bin/sudo /usr/local/bin/framework_tool --charge-limit"
batcc_usage="usage: batcc <percent>; ${lower_limit} <= <percent> <= ${upper_limit}"
if [ -z "${1}" ]; then
echo "${batcc_usage}"
$batcc_status
return 1
else
limit="${1}"
fi
if [ "${limit}" -ge "${lower_limit}" -a "${limit}" -le "${upper_limit}" ]; then
/usr/bin/sudo systemctl restart batcc@${limit}
$batcc_status
else
echo "${batcc_usage}"
return 1
fi
} # END batcc
batcc@.service:
[Unit]
Description=Set a maximum percent charge limit via framework_tool
[Service]
Type=oneshot
ExecStart=/bin/sh -c '/usr/local/bin/framework_tool --charge-limit %I'
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
The above has been working for me with kubuntu 24.04 lts and a 6.14 kernel.