Compare commits

..

No commits in common. "3be229141da02755553f8d282c4ee4be91ffea00" and "a8b3862bea59215e22db9e7db41f09a91c651030" have entirely different histories.

5 changed files with 5 additions and 60 deletions

1
.gitignore vendored
View file

@ -1,2 +1 @@
.venv/ .venv/
**/__pycache__/

23
main.py
View file

@ -24,22 +24,11 @@ def bluetooth_connect(args):
print("%s",process.stderr) print("%s",process.stderr)
def pipewire_list(args): def pipewire_list(args):
print("ID | Description") print(args)
print("----------------")
sinks = Pipewire.get_sinks() sinks = Pipewire.get_sinks()
for sink in sinks: for sink in sinks:
print(str(sink['id']) + " | " + sink['info']['props']['node.description']) print(sink['info']['props']['node.description'])
def pipewire_get_default_sink(args):
print("ID | Description")
print("----------------")
sink = Pipewire.get_default_audio_sink()
print(str(sink['id']) + " | " + sink['info']['props']['node.description'])
def pipewire_get_volume(args):
print(Pipewire.get_volume())
def main(): def main():
argparser = argparse.ArgumentParser(description='CarPI CLI.') argparser = argparse.ArgumentParser(description='CarPI CLI.')
@ -52,17 +41,11 @@ def main():
action_bt_connect = actions.add_parser('bluetooth-connect', help='connect to a bluetooth device') action_bt_connect = actions.add_parser('bluetooth-connect', help='connect to a bluetooth device')
action_bt_connect.set_defaults(func=bluetooth_connect) action_bt_connect.set_defaults(func=bluetooth_connect)
action_bt_connect.add_argument('address', help='the bluetooth address of the device to connect to.') action_bt_connect.add_argument('address', help='The bluetooth address of the device to connect to.')
action_pw_list = actions.add_parser('pipewire-list', help='list pipewire objects') action_pw_list = actions.add_parser('pipewire-list', help='list pipewire objects')
action_pw_list.set_defaults(func=pipewire_list) action_pw_list.set_defaults(func=pipewire_list)
action_pw_get_default_sink = actions.add_parser('pipewire-get-default-sink', help='show the default audio sink')
action_pw_get_default_sink.set_defaults(func=pipewire_get_default_sink)
action_pw_get_volume = actions.add_parser('pipewire-get-volume', help='get volume of the specified device')
action_pw_get_volume.set_defaults(func=pipewire_get_volume)
args = argparser.parse_args() args = argparser.parse_args()
args.func(args) args.func(args)

View file

View file

@ -38,11 +38,5 @@ class Pipewire:
for node in nodes: for node in nodes:
if (node['type'] == 'PipeWire:Interface:Node' and if (node['type'] == 'PipeWire:Interface:Node' and
node['info']["props"]['node.name'] == default_skink): node['info']["props"]['node.name'] == default_skink):
return(node) print(node['info']['props']['node.description'])
return(node)
def get_volume(id=None):
if id == None:
id = "@DEFAULT_AUDIO_SINK@"
return subprocess.run(["wpctl", "get-volume", id],
stdout=subprocess.PIPE, text=True).stdout.split()[1]

31
tmp.py
View file

@ -1,31 +0,0 @@
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