Skip to content

Commit

Permalink
lighter cmd read ins :)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuannan committed Feb 19, 2021
1 parent 1eeaf6c commit b56cda2
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions panon/backend/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,20 +116,13 @@ def update_smart_device(self, ):
if not self.device_id == 'smart':
return
import subprocess
s = subprocess.run(['pacmd', 'list-sink-inputs'], capture_output=True).stdout
l = s.decode(errors='ignore').split('\n')
name = None
for line in l:
if line.startswith('\tstate: '):
state = line.split()[-1]
if line.startswith('\tsink: '):
if state == 'RUNNING':
name = line.split('<')[-1][:-1]
break
s = subprocess.run(['pactl', 'list', 'sink-inputs', 'short'], capture_output=True).stdout
l = s.decode(errors='ignore').split('\t')
new_id = l[1]

if name is not None:
if not self.smart_device_id == name:
self.smart_device_id = name
if not self.smart_device_id == new_id:
self.smart_device_id = new_id
for stream in self.streams:
stream.__exit__(None, None, None)

Expand All @@ -139,7 +132,7 @@ def update_smart_device(self, ):
except (AttributeError, NotImplementedError):
pass
mic = sc.get_microphone(
self.smart_device_id + '.monitor',
self.smart_device_id,
include_loopback=False,
exclude_monitors=False,
)
Expand Down

0 comments on commit b56cda2

Please sign in to comment.