31 lines
No EOL
883 B
Python
31 lines
No EOL
883 B
Python
import json
|
|
import subprocess
|
|
import pprint
|
|
|
|
pwdump = subprocess.run(['pw-dump'], stdout=subprocess.PIPE, text=True)
|
|
|
|
nodes = json.loads(pwdump.stdout)
|
|
|
|
# LIST SINKS
|
|
#for node in nodes:
|
|
# try:
|
|
# if node['type'] == 'PipeWire:Interface:Node':
|
|
# if node['info']["props"]['media.class'] == 'Audio/Sink':
|
|
# print(node['info']['props']['node.description'])
|
|
# except KeyError:
|
|
# pass
|
|
|
|
|
|
# RETURN DESCRIPTION OF DEFAULT AUDIO DEVICE
|
|
for node in nodes:
|
|
if (node['type'] == 'PipeWire:Interface:Metadata' and
|
|
node['props']['metadata.name'] == 'default'):
|
|
for metadata in node['metadata']:
|
|
if metadata['key'] == 'default.audio.sink':
|
|
default_skink = metadata['value']['name']
|
|
break
|
|
|
|
for node in nodes:
|
|
if (node['type'] == 'PipeWire:Interface:Node' and
|
|
node['info']["props"]['node.name'] == default_skink):
|
|
print(node['info']['props']['n |