tshakalekholoane/bat

Charge threshold doesn't work with suspend-then-hibernate

GWFrank opened this issue · 2 comments

Expected Behavior

After resuming from suspend-then-hibernate, if battery level is above charge threshold (80), it shouldn't be charging.

Actual Behavior

The battery is charging despite that battery level is above threshold (80) after resuming from suspend-then-hibernate.
bat -t correctly shows the threshold I configured. Manually setting charge threshold again makes it work properly.

Steps to reproduce

  1. Set threshold and persist. sudo bat -t 80 sudo bat -p.
  2. Set appropriate HibernateDelaySec (like 20 for testing) in /etc/systemd/sleep.conf.
  3. Charge the battery until it meets the threshold. Check that the battery is not charging with bat -s.
  4. sudo systemctl suspend-then-hibernate and wait for it to enter hibernate mode.
  5. Resume from hibernate. Check battery status with bat -s and it says it's charging.
  6. Run sudo bat -t 80 then check battery status. This time the threshold works and battery isn't charging.

Additional Notes

With both suspend and hibernate the threshold works properly.
I tried both 0.8 and 0.8.1, neither works.

System Info

OS: Manjaro Linux x86_64 
Host: ZenBook UX425EA_UX425EA 1.0 
Kernel: 5.13.8-1-MANJARO 
Packages: 1373 (pacman), 5 (flatpak), 10 (snap) 
Shell: zsh 5.8 
Resolution: 1920x1080 
DE: Plasma 5.22.4 
WM: KWin 
CPU: 11th Gen Intel i5-1135G7 (8) @ 4.200GHz 
GPU: Intel TigerLake-LP GT2 [Iris Xe Graphics] 
Memory: 2203MiB / 15701MiB 

Thank you for filing the issue. Here's a proposed fix. Let me know if works and confirm that the version is 0.8.2-alpha before running it.

After using the new version to do sudo bat -t 80 and sudo bat -p then reboot the system, it seems to work !