get-volume
This commit is contained in:
parent
d00cc46aaf
commit
3be229141d
4 changed files with 45 additions and 2 deletions
6
main.py
6
main.py
|
@ -38,6 +38,9 @@ def pipewire_get_default_sink(args):
|
|||
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.')
|
||||
|
||||
|
@ -57,6 +60,9 @@ def main():
|
|||
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