Skip to content

Commit

Permalink
add wireplumber selector
Browse files Browse the repository at this point in the history
  • Loading branch information
wizzdom committed Apr 30, 2024
1 parent 12fb79f commit 0074695
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions wp-devices.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#! /usr/bin/env python3

import subprocess

# I use this for bemenu since sway won't pick up it up
MENU_OPTIONS = ''
# MENU_OPTIONS = '-H 32 -I 0 -i -m 0 --fn "Hack:14" --fb "#323232" --ff "#ffffff" --nb "#323232" --nf "#ffffff" --sf "#ffffff" --sb "#81a2be" --af "#ffffff" --ab "#323232" --tb "#81a2be" --tf "#ffffff" --hb "#81a2be" --hf "#ffffff"'

dmenu = 'wofi -d'

sp = subprocess.run(['wpctl', 'status'], stdout=subprocess.PIPE).stdout.decode('utf-8')\
.split("Sinks")[1].split('├─')[0]
newsp = []

for line in sp.split('\n'):
if '.' in line:
newsp.append(line.replace(' ', '')[1:])

devices = {} # name: id
for line in newsp:
line = line.split('.')
devices[line[1].split('[vol')[0]] = line[0].replace('*', '')

devices_list = '\\n'.join(devices.keys())

device_choice = subprocess.Popen(f'echo -e \"{devices_list}\" | {dmenu} -p "Choose Device"' + MENU_OPTIONS, shell=True, stdout=subprocess.PIPE)\
.stdout.read().decode('utf-8')
device_choice = device_choice.replace('\n', '')
device_choice = devices[device_choice]

subprocess.Popen('wpctl set-default '+str(device_choice),
shell=True, stdout=subprocess.PIPE)

0 comments on commit 0074695

Please sign in to comment.