add charging watchdog

This commit is contained in:
Frank Zechert
2026-08-18 12:25:15 +02:00
parent 2e546e1ebb
commit aed8cf9dd3
5 changed files with 280 additions and 7 deletions
@@ -0,0 +1,32 @@
[Unit]
Description=Battery charge-controller fault watchdog
Documentation=man:notify-send(1)
# Needs the session bus for notifications.
After=graphical-session.target
PartOf=graphical-session.target
# Makes the unit inert on machines without a battery, so it can be
# enabled unconditionally on the desktop as well as the laptop.
ConditionPathExists=/sys/class/power_supply/BAT0/charge_now
[Service]
Type=simple
ExecStart=%h/.config/scripts/battery-charge-watchdog.sh
Restart=always
RestartSec=10
# Set HIBERNATE_AT=5 to add an emergency hibernate floor (0 = notify only).
Environment=POLL_INTERVAL=20
Environment=REPEAT_INTERVAL=60
Environment=DROP_PERMILLE=15
Environment=HIBERNATE_AT=0
# Read-only monitoring; no need for any write access to the system.
ProtectSystem=strict
ProtectHome=read-only
PrivateTmp=yes
NoNewPrivileges=yes
RestrictNamespaces=yes
MemoryMax=64M
[Install]
WantedBy=graphical-session.target