Skip to content

Instantly share code, notes, and snippets.

@JakeTrock
Created November 23, 2020 15:23
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JakeTrock/6158cb81117605d75603fa637e72fd66 to your computer and use it in GitHub Desktop.
Save JakeTrock/6158cb81117605d75603fa637e72fd66 to your computer and use it in GitHub Desktop.
#! /usr/bin/python
#improvement of Weslley S Pereira's script by Jacob Trock
try:
# Python2
import Tkinter as tk
except ImportError:
# Python3
import tkinter as tk
import os
v = "88_D0_39_6C_6E_AC"
def toggle(tog=[0]):
tog[0] = not tog[0]
if tog[0]:
os.system('pacmd set-card-profile bluez_card.' + v + ' headset_head_unit')
t_btn.config(text='Switch Mic Off')
else:
os.system('pacmd set-card-profile bluez_card.' + v + ' a2dp_sink')
t_btn.config(text='Switch Mic On')
root = tk.Tk()
root.title('Toggler')
e = tk.Entry(textvariable=v)
e.insert(0, v)
e.pack()
t_btn = tk.Button(text='Switch Mic On', width=15, command=toggle)
t_btn.pack(pady=5)
root.mainloop()
@pbackx
Copy link

pbackx commented Jul 27, 2021

Thanks, just for reference, use pacmd list-cards when the bluetooth headset is connected to find the value for v

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment