Finally got battery monitoring working reliably. This was a hell of a lot harder than it should have been.

This commit is contained in:
Storm Dragon
2025-08-09 05:13:36 -04:00
parent 9159fcac43
commit e0fff64aff
2 changed files with 116 additions and 41 deletions
+13 -18
View File
@@ -1,32 +1,27 @@
[Unit]
Description=Battery Monitor for Stormux Gaming Image
Documentation=man:battery_monitor.py(1)
After=multi-user.target
After=multi-user.target sound.target
ConditionPathExists=/sys/class/power_supply
[Service]
Type=simple
ExecStart=/usr/local/bin/battery_monitor.py
Restart=always
RestartSec=10
User=root
Group=root
RestartSec=30
User=stormux
Group=stormux
# Security settings
NoNewPrivileges=yes
ProtectSystem=strict
ProtectHome=yes
ProtectKernelTunables=yes
ProtectKernelModules=yes
ProtectControlGroups=yes
ReadWritePaths=/var/log
ReadOnlyPaths=/sys/class/power_supply
# Allow access to system resources
SupplementaryGroups=audio video
# Allow access to speech and audio
SupplementaryGroups=audio
# Environment
# Environment for audio and speech
Environment=PYTHONUNBUFFERED=1
Environment=XDG_RUNTIME_DIR=/run/user/1000
Environment=PULSE_RUNTIME_PATH=/run/user/1000/pulse
# Allow sudo for shutdown without password
# This requires sudoers configuration
[Install]
WantedBy=multi-user.target
WantedBy=default.target