Limit max battery charging on ChimeraOS
##
Intro
ChimeraOS is a great SteamOS-alternative, which serves as an appliance, that appliance introduces the ItJustWorks-factor, but hinders the “I want to edit-something”-factor.
I use it on a ROG Ally, primarily docked, but I don’t want to have the battery constantly charged to 100%.
#
Systemd to the rescue.
mkdir -p /home/gamer/.config/systemd/user/
/home/gamer/.config/systemd/user/battery-limiter.service
[Unit]
Description=Battery Limiter
[Service]
Type=simple
ExecStart=/home/gamer/battery-limit.sh
/home/gamer/.config/systemd/user/battery-limiter.timer
[Unit]
Description=Battery Limiter
[Timer]
Unit=battery-limiter.service
OnBootSec=15m
OnUnitInactiveSec=15m
OnActiveSec=1s
[Install]
WantedBy=timers.target
Replace INSERTPASSWORDHERE
with the currently set password for the gamer-account, by default that is gamer.
/home/gamer/battery-limit.sh
#!/bin/bash
echo INSERTPASSWORDHERE | sudo -S /bin/bash -c 'echo 60 > /sys/class/power_supply/BAT0/charge_control_end_threshold'
Activate the timer/service/exec
mkdir -p /home/gamer/.config/systemd/user/timers.target.wants
ln -s /home/gamer/.config/systemd/user/regular-maintenance.timer /home/gamer/.config/systemd/user/timers.target.wants/regular-maintenance.timer
chmod +x /home/gamer/battery-limit.sh
systemctl --user daemon-reload
systemctl --user enable --now battery-limiter.service
systemctl --user enable --now battery-limiter.timer
##
Outro
Last tested on ChimeraOS 49.