Add web mixer with native input volume and output selection

This commit is contained in:
jsahn
2026-10-12 18:45:43 +09:00
parent ceef64dfed
commit 5fbece12bb
19 changed files with 696 additions and 34 deletions
+14 -5
View File
@@ -8,10 +8,18 @@ import subprocess
import sys
UNITS = ['shairport-sync', 'nqptp', 'bluealsa', 'bluealsa-aplay',
'radxa-bt-output', 'radxa-bose-output', 'avahi-daemon', 'bluetooth']
'radxa-bt-output', 'radxa-bose-output', 'radxa-mixer-web', 'avahi-daemon', 'bluetooth']
PATHS = [
'/etc/systemd/system/radxa-mixer-web.service',
'/etc/dbus-1/system.d/shairport-sync-dbus.conf',
'/usr/local/lib/radxa-mixer/input_controls.py',
'/usr/local/lib/radxa-mixer/web_server.py',
'/usr/local/lib/radxa-mixer/web/index.html',
'/usr/local/lib/radxa-mixer/web/app.js',
'/usr/local/lib/radxa-mixer/web/style.css',
'/etc/asound.conf', '/etc/shairport-sync.conf',
'/etc/radxa-audio/mixer.json', '/etc/radxa-audio/asound-dac.conf',
'/etc/radxa-audio/input-memory.json',
'/etc/radxa-audio/asound-bluetooth.conf',
'/etc/systemd/system/shairport-sync.service', '/etc/systemd/system/nqptp.service',
'/etc/systemd/system/bluealsa.service.d/10-radxa-sink.conf',
@@ -48,9 +56,9 @@ def snapshot(directory):
def restore(directory):
manifest = json.loads((directory / 'manifest.json').read_text())
# Only restore allowlisted paths from our own snapshot.
if set(manifest['files']) != set(PATHS) or set(manifest['units']) != set(UNITS):
if not set(manifest['files']).issubset(PATHS) or not set(manifest['units']).issubset(UNITS):
raise ValueError('알 수 없는 백업 형식입니다.')
for unit in UNITS[:6]: ctl('stop', unit)
for unit in UNITS[:7]: ctl('stop', unit)
for name, existed in manifest['files'].items():
target = Path(name)
if existed:
@@ -60,11 +68,12 @@ def restore(directory):
else:
target.unlink(missing_ok=True)
ctl('daemon-reload')
for unit, state in manifest['units'].items():
for unit in UNITS:
state = manifest['units'].get(unit, {'active': False, 'enabled': False})
ctl('enable' if state['enabled'] else 'disable', unit)
# Bluetooth and Avahi may have been started by apt during installation.
for unit in reversed(UNITS):
state = manifest['units'][unit]
state = manifest['units'].get(unit, {'active': False, 'enabled': False})
result = ctl('restart' if state['active'] else 'stop', unit)
if state['active'] and result.returncode:
print(result.stdout, file=sys.stderr)