-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbluealsaautofix.py
executable file
·34 lines (27 loc) · 1.16 KB
/
bluealsaautofix.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env python3
import setproctitle
import sys
import subprocess
import time
checkTimerInSeconds = 1
configFileLocation = "/etc/bluealsaaplay.conf"
#configFileLocation = "/tmp/bluealsaaplay.conf"
if __name__ == "__main__":
setproctitle.setproctitle("bluealsaautofix")
while True:
#result = subprocess.run(["moodeutl", "-q", "'select value from cfg_system where param='wrkready''"], stdout=subprocess.PIPE)
result = subprocess.run(["echo", "1"], stdout=subprocess.PIPE)
resultAsString = result.stdout.decode('utf-8')
if resultAsString == "1\n":
print("startup has completed")
with open(configFileLocation, "w") as configFile:
configFile.write("AUDIODEV=alsaequal\n")
configFile.write("BUFFERTIME=500000\n")
print("configured blue alsa aplay successfully, exiting")
sys.exit(0)
elif resultAsString == "0\n":
print("startup has not yet completed, waiting for it to happen")
time.sleep(1)
else:
sys.stderr.write(f"got unexpected result '{resultAsString}', exiting")
sys.exit(1)