LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Desktop (https://www.linuxquestions.org/questions/linux-desktop-74/)
-   -   How do I toggle the microphone with a command or with Autokey (https://www.linuxquestions.org/questions/linux-desktop-74/how-do-i-toggle-the-microphone-with-a-command-or-with-autokey-4175654480/)

jamesd1 05-23-2019 07:48 PM

How do I toggle the microphone with a command or with Autokey
 
How do I toggle the microphone with a keyboard short cut, a command or with Autokey

Desktop: MATE 1.20.1 Distro: Linux Mint 19.1 Tessa

evo2 05-23-2019 08:12 PM

Hi,

assuming that it is the first microphone and that you are using pulse audio
Code:

pactl set-source-mute 1 toggle
Run pavucontrol and look at the "Input Devices" tab, and also run "pactl subscribe" in another to confirm what is happening.

Cheers,

Evo2.

jamesd1 05-23-2019 09:00 PM

Under hardware/sound I found:
Choose a device for sound input:
© AK5370 I/F A/D Converter Analog Mono
©) Built-in Audio Analog Stereo

The above has a radio box that toggles the Microphone

--------------------------


pactl set-source-mute 1 toggle

nothing happend and no feedback and no toggle of microphone.


james@james-desktop:~$ pactl subscribe
Event 'change' on source-output #2224
Event 'remove' on source-output #2224
Event 'new' on source-output #2225
Event 'change' on source-output #2225
Event 'change' on source-output #2225
Event 'remove' on source-output #2225
Event 'new' on source-output #2226
Event 'change' on source-output #2226
Event 'change' on source-output #2226
Event 'remove' on source-output #2226
Event 'new' on source-output #2227
Event 'change' on source-output #2227
Event 'change' on source-output #2227
Event 'remove' on source-output #2227
Event 'new' on source-output #2228
Event 'change' on source-output #2228
Event 'change' on source-output #2228
Event 'remove' on source-output #2228
Event 'new' on source-output #2229
Event 'change' on source-output #2229
Event 'change' on source-output #2229
Event 'remove' on source-output #2229
Event 'new' on source-output #2230
Event 'change' on source-output #2230

evo2 05-23-2019 09:24 PM

Hi,

qhat do you see from "pactl subscribe" when you toggle the microphone using pavucontrol (or some other gui tool)? You should see something like:
Code:

Event 'change' on source #1
I this case "1" is index for source (microphone). Presumably for you it is something else. Maybe 0, maybe 2 etc. Once you know that index you should be able to use:
Code:

pactl set-source-mute N toggle
Where N is the index for your microphone.

Evo2.

Shadow_7 05-23-2019 09:34 PM

Do you mean like a hardware toggle? Cause many apps have built in toggles. Skype, mumble, and things have keys you can set to USE the microphone, otherwise it's muted. And probably settings to avoid the hassle as well. If it's not in use you can modprobe -r the module for the sound card. I have a headphone preamp for my output that has a mute (and mono) toggle button. In terms of microphones (external) you can just unplug them. The advantage of an XLR connection is that it doesn't pop when you plug/unplug it. Versus TRS that does pop. A lot of interfaces have gain knobs, not technically muted, but you can turn those down to inaudible levels.

jamesd1 05-23-2019 09:57 PM

james@james-desktop:~$ pactl subscribe
Event 'change' on sink #0

but:

james@james-desktop:~$ pactl set-source-mute 0 toggle
james@james-desktop:~$

Gives no feedback and there is no change in microphone state.

evo2 05-23-2019 10:18 PM

Hmm, strange.

Do you see anything change in "Input Devices" tab (with "All Input Devices" selected) in pavucontrol when you run "pactl set-source-mute 0 toggle"?

Evo2.

hydrurga 05-23-2019 10:37 PM

Just to confirm that evo2's command:

Code:

pactl set-source-mute 1 toggle
works perfectly in muting my internal microphone, tested by recording my voice in Audacity and running the command twice in the middle of the recording to mute my microphone and then unmute it again.

Mint 19.1 MATE.

jamesd1 05-24-2019 07:44 AM

SOLVED
 
Not sure what I did wrong yesterday but this moring:

pactl set-source-mute 0 toggle

Worked to toggle my microphone.

Thanks.


Quote:

Originally Posted by hydrurga (Post 5998310)
Just to confirm that evo2's command:

Code:

pactl set-source-mute 1 toggle
works perfectly in muting my internal microphone, tested by recording my voice in Audacity and running the command twice in the middle of the recording to mute my microphone and then unmute it again.

Mint 19.1 MATE.


hydrurga 05-24-2019 09:08 AM

Quote:

Originally Posted by jamesd1 (Post 5998404)
Not sure what I did wrong yesterday but this moring:

pactl set-source-mute 0 toggle

Worked to toggle my microphone.

Thanks.

Great to hear. You can also connect this command to a keystroke sequence:

Control Centre->Hardware->Keyboard Shortcuts->Add->Name:Toggle Microphone, Command: pactl set-source-mute 0 toggle->Apply.

Then click on "Disabled" beside the command & press Ctrl+Shift+Esc (or whichever key sequence you require).

Close that window and try it out.


All times are GMT -5. The time now is 08:51 AM.