.bin/pulseaudio-assert-volume: add some flushing to print()

This commit is contained in:
Franzi 2021-07-09 19:36:14 +02:00
parent d4400473a0
commit 507f24e7b4
Signed by: kunsi
GPG key ID: 12E3D2136B818350

View file

@ -14,7 +14,7 @@ signal(SIGTERM, handle_signal)
try: try:
print('Startup') print('Startup', flush=True)
while True: while True:
try: try:
@ -31,12 +31,12 @@ try:
if line.startswith('volume:'): if line.startswith('volume:'):
for speaker, absolute, percent in findall('([a-z-]+):\W+([0-9]+)\W+\/\W+([0-9]+)%', line): for speaker, absolute, percent in findall('([a-z-]+):\W+([0-9]+)\W+\/\W+([0-9]+)%', line):
if int(percent) < 100: if int(percent) < 100:
print(f' sink {sink_id} speaker {speaker} at {percent} % volume') print(f' sink {sink_id} speaker {speaker} at {percent} % volume', flush=True)
needs_adjusting = True needs_adjusting = True
if needs_adjusting: if needs_adjusting:
check_output(['pactl', 'set-sink-input-volume', sink_id, '100%']) check_output(['pactl', 'set-sink-input-volume', sink_id, '100%'])
print(f' adjusted sink {sink_id} to 100%') print(f' adjusted sink {sink_id} to 100%', flush=True)
needs_adjusting = False needs_adjusting = False
@ -45,4 +45,4 @@ try:
sleep(0.5) sleep(0.5)
finally: finally:
print('Shutdown') print('Shutdown', flush=True)