Update __main__.py

New CLI helpers

    Added support for:

    script/run --list-input-devices
    script/run --list-output-devices

    These code paths:

        Initialize just enough of the audio stack to enumerate devices.

        Print a clean, human-readable list of input/output devices (including PipeWire / PulseAudio virtual devices like Echo-Cancel Source and pipewire/echo-cancel-sink).

        Exit cleanly with status 0 instead of trying to start the full LVA process afterward (fixing the previous CalledProcessError when --list-output-devices was used).

Behavior change

    __main__.py now treats the “list devices” modes as early-exit utility modes, not “run LVA and then also print devices”.

    This makes it practical to use these commands in setup docs and shell scripts.
This commit is contained in:
imonlinux
2025-11-20 20:02:23 -08:00
committed by GitHub
parent 0151b64810
commit adbb37e731
+4 -1
View File
@@ -171,13 +171,16 @@ def _init_basics() -> Tuple[Config, asyncio.AbstractEventLoop, EventBus]:
if args.list_output_devices: if args.list_output_devices:
print("Output devices\n" + "=" * 14) print("Output devices\n" + "=" * 14)
exit_code = 0
try: try:
player = MpvMediaPlayer(loop=None) player = MpvMediaPlayer(loop=None)
for speaker in player.player.audio_device_list: for speaker in player.player.audio_device_list:
print(speaker["name"] + ":", speaker["description"]) print(speaker["name"] + ":", speaker["description"])
except Exception as e: except Exception as e:
_LOGGER.error("Failed to list output devices: %s", e) _LOGGER.error("Failed to list output devices: %s", e)
sys.exit(1) exit_code = 1
sys.exit(exit_code)
config_path = args.config config_path = args.config
if not config_path.is_absolute(): if not config_path.is_absolute():