26 lines
693 B
Python
26 lines
693 B
Python
#!/usr/bin/env python3
|
|
|
|
import random
|
|
import subprocess
|
|
import sys
|
|
import time
|
|
|
|
def play_sfx(jack_name: str, filename: str):
|
|
subprocess.call(['mpv', '--no-video', '--ao=jack', f'--jack-port={jack_name}', filename])
|
|
|
|
def main(argv: list[str]):
|
|
if len(argv) < 5:
|
|
print(f"Usage: {argv[0]} <jack-output> <min-delay> <max-delay> <...files>")
|
|
exit(1)
|
|
|
|
jack_output = sys.argv[1]
|
|
min_delay = int(sys.argv[2])
|
|
max_delay = int(sys.argv[3])
|
|
audio_files = sys.argv[4:]
|
|
while True:
|
|
time.sleep(random.randint(min_delay, max_delay))
|
|
sfx = random.choice(audio_files)
|
|
play_sfx(jack_output, sfx)
|
|
|
|
if __name__ == '__main__':
|
|
main(sys.argv)
|