Running Ubuntu 20.04.
In order to conserve battery life, I have a service that runs at boot that will cap the charge level to 80%, see service below (/etc/systemd/system/battery-charge-threshold.service):
[Unit]
Description=Set the battery charge threshold
After=multi-user.target
StartLimitBurst=0
[Service]
Type=oneshot
Restart=on-failure
ExecStart=/bin/bash -c 'echo 80 > /sys/class/power_supply/BAT0/charge_control_end_threshold'
[Install]
WantedBy=multi-user.target
This works well, and is even sustained after shutdown of my computer. During the initial boot of the computer BIOS/UEFI, the setting seem to be reset to 100% (indicated by charging LED indicator on the laptop switching from "Full" to "Charging" light). However, once Ubuntu is booted, the service runs and the limit is again set to 80%. The setting is sustained in s2idle and resume from s2idle, but when resuming from hibernate the service does not seem to be run, and the limit is thus at 100%. After resume, I can activate the service using
sudo systemctl start battery-charge-threshold.service
and everything works again. However, I would like to have the service run automatically at resume from hibernate. I have seen how to make this happen on resume from s2idle or suspend, but I have not been able to find anything on how to make this happen with hibernate.
Anyone know how to approach this?