-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathUniPause.py
More file actions
68 lines (48 loc) · 1005 Bytes
/
UniPause.py
File metadata and controls
68 lines (48 loc) · 1005 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import os
import subprocess
import serial
db_space=['saavn','']
db_k=['youtube']
db_med=['']
def namegetter(x):
name_list=[]
strbuff=""
read=False
stopread=False
for i in x:
if i=='"':
if read:
stopread=True
read=~read
continue
if read:
strbuff+=i
if stopread:
stopread=False
pid_list.append(str(strbuff))
strbuff=""
return name_list
def pauser():
to_pause=[]
noiseMakers=subprocess.check_output('pacmd list-sink-inputs| grep -e application.name ',shell=True)
noiseMakers=str(noiseMakers)
to_pause=namegetter(noiseMakers)
for i in to_pause:
os.system('xdotool search --name '+str(i)+'')
return to_pause
def resumer(x):
for i in x:
os.system('kill -CONT '+str(i))
def main():
paused=False
ser=serial.Serial('/dev/ttyACM0',9600)
while True:
p=ser.readline()
if (p[:4]==b'play' and paused):
resumer(frozen)
paused=False
if (p[:5]==b'pause' and ~paused):
frozen=pauser()
paused=True
if __name__ == '__main__':
main()