Compare commits
4 commits
a8b3862bea
...
3be229141d
Author | SHA1 | Date | |
---|---|---|---|
|
3be229141d | ||
|
d00cc46aaf | ||
|
6ddd91e339 | ||
|
f1df74bcfc |
5 changed files with 60 additions and 5 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1 +1,2 @@
|
|||
.venv/
|
||||
**/__pycache__/
|
||||
|
|
23
main.py
23
main.py
|
@ -24,11 +24,22 @@ def bluetooth_connect(args):
|
|||
print("%s",process.stderr)
|
||||
|
||||
def pipewire_list(args):
|
||||
print(args)
|
||||
print("ID | Description")
|
||||
print("----------------")
|
||||
|
||||
sinks = Pipewire.get_sinks()
|
||||
for sink in sinks:
|
||||
print(sink['info']['props']['node.description'])
|
||||
print(str(sink['id']) + " | " + 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():
|
||||
argparser = argparse.ArgumentParser(description='CarPI CLI.')
|
||||
|
@ -41,11 +52,17 @@ def main():
|
|||
|
||||
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.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.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.func(args)
|
||||
|
||||
|
|
0
src/bluetooth.py
Normal file
0
src/bluetooth.py
Normal file
|
@ -38,5 +38,11 @@ class Pipewire:
|
|||
for node in nodes:
|
||||
if (node['type'] == 'PipeWire:Interface:Node' and
|
||||
node['info']["props"]['node.name'] == default_skink):
|
||||
print(node['info']['props']['node.description'])
|
||||
return(node)
|
||||
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
Normal file
31
tmp.py
Normal file
|
@ -0,0 +1,31 @@
|
|||
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
|
Loading…
Add table
Reference in a new issue