-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathscript.py
More file actions
30 lines (24 loc) · 757 Bytes
/
script.py
File metadata and controls
30 lines (24 loc) · 757 Bytes
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
#!/bin/env python
import os
import time
connected =False
counter = 0
os.system("amixer cset numid=3 1")
os.system("amixer set Master 100%")
os.system("pacmd set-sink-volume 0 65537")
# while (connected =FALSE)
#edit wait time, to search for devices 1 unit = 2 sec , 3 would give six seconds
WAIT=4
while((counter<=WAIT)and(connected==False)):
response=os.popen('pactl list sources short')
text=response.read()
if(text.find("bluez")<0):
print("i am sleeping")
time.sleep(2);
else:
# edit this line to add your phone's bluetooth MAC
connected= True
os.system("pactl load-module module-loopback source=bluez_source.50_EA_D6_DE_D9_39 sink=alsa_output.platform-bcm2835_AUD0.0.analog-stereo")
counter=3
counter+=1
response.close();