WizardKit/scripts/wk/hw/audio.py
2Shirt 8d70c7bfc6
Use patcl to adjust the volume for speaker-test
Needed due to the switch to pipewire and pulseaudio.
2022-07-09 20:05:38 -07:00

40 lines
870 B
Python

"""WizardKit: Audio test functions"""
# vim: sts=2 sw=2 ts=2
import logging
from wk.exe import run_program
from wk.std import PLATFORM
# STATIC VARIABLES
LOG = logging.getLogger(__name__)
# Functions
def audio_test() -> None:
"""Run an OS-specific audio test."""
if PLATFORM == 'Linux':
audio_test_linux()
def audio_test_linux() -> None:
"""Run an audio test using amixer and speaker-test."""
LOG.info('Audio Test')
# Set volume
commands = (
'pactl set-sink-mute @DEFAULT_SINK@ off',
'pactl set-sink-volume @DEFAULT_SINK@ 80%',
)
for cmd in commands:
run_program(cmd.split(), check=False)
# Run audio tests
for mode in ('pink', 'wav'):
cmd = f'speaker-test -c 2 -l 1 -t {mode}'
run_program(cmd.split(), check=False, pipe=False)
if __name__ == '__main__':
print("This file is not meant to be called directly.")