mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-10-13 10:36:35 +00:00
feat(web): Start Display on Boot toggle on the General tab
Turns ledmatrix.service's autostart on or off at once through the existing enable_autostart / disable_autostart system actions (sudo grants already in lib_sudoers.sh). The checkbox shows systemd's own state, read with `systemctl is-enabled`, so nothing is stored in config.json and the default stays on. Hidden when the state cannot be read; a refused change puts the box back and shows the route's message. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -4,6 +4,7 @@ from html.parser import HTMLParser
|
||||
import json
|
||||
import logging
|
||||
import re
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
# Strict allowlists for URL-derived values used in path and script operations.
|
||||
@@ -487,9 +488,25 @@ def _load_general_partial():
|
||||
main_config=main_config,
|
||||
auto_update_status=auto_update_status,
|
||||
update_channel_status=update_channel_status,
|
||||
display_autostart=_display_autostart_state(),
|
||||
web_login=_web_login_state())
|
||||
|
||||
|
||||
def _display_autostart_state():
|
||||
"""Whether ledmatrix.service starts at boot; None hides the toggle.
|
||||
|
||||
systemd's enablement is the setting itself (the installer enables the
|
||||
unit), so nothing is stored in config.json. None when it cannot be read:
|
||||
no systemctl (a dev machine) or the unit is not installed.
|
||||
"""
|
||||
try:
|
||||
result = subprocess.run(['systemctl', 'is-enabled', 'ledmatrix.service'],
|
||||
capture_output=True, text=True, timeout=5)
|
||||
except (OSError, subprocess.SubprocessError):
|
||||
return None
|
||||
return {'enabled': True, 'disabled': False}.get(result.stdout.strip())
|
||||
|
||||
|
||||
def _web_login_state():
|
||||
"""What the General tab's Security section shows; None hides it.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user