Created
November 23, 2020 15:23
-
-
Save JakeTrock/6158cb81117605d75603fa637e72fd66 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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() |
glad you liked it!
It giving me below error
Failed to set card profile to 'headset_head_unit'
this is because that profile does not exist on your headset. perhaps this is an error with your sound system or your headset. Id suggest you turn it off then on again and see if anything changes. If not, then if you're on linux, then you should take a look at pulseaudio and your current bluetooth configs
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
Thank you, this works beautifully, just modified v = "88_D0_39_6C_6E_AC" to my version of bluez_card and it works like a charm.