Just in case anyone needs it. I use it for Jitsi, slack, teams, zoom and other browser conference software like that.

Find out your microphone name

pactl list sources|grep "Name:"

This will give you a list of available sources. Find the correct name for your preferred microphone.

Mute and unmute via command

# unmute
pactl set-source-mute <MICROPHONE> 0
# mute
pactl set-source-mute <MICROPHONE> 1

Adding it as a key binding to i3

Add this to your i3 config:

bindsym Mod1+space exec --no-startup-id pactl set-source-mute <MICROPHONE> 0
bindsym --release Mod1+space exec --no-startup-id pactl set-source-mute <MICROPHONE> 1

Replace <MICROPHONE> with your preferred microphone (without < and >).

This will add an Alt(Mod1) + Space bar keybind that unmutes the microphone when pressed and mutes when released.

This is how it is set for my microphone:

bindsym Mod1+space exec --no-startup-id pactl set-source-mute alsa_input.usb-046d_0825_89361D50-02.analog-mono 0
bindsym --release Mod1+space exec --no-startup-id pactl set-source-mute alsa_input.usb-046d_0825_89361D50-02.analog-mono 1

I also set a 3rd keybinding that just unmutes, but doesn't mute on release. This way I can set it to constantly record.

Continuous mode

If you want a button to toggle continuous mode (always recording) you can simply set an additional button but without --release. To undo it you can simply press your other push-to-talk button once.

bindsym Mod1+space exec --no-startup-id pactl set-source-mute <MICROPHONE> 0

Using a mouse button

I wanted an additional keybinding for my mouse button 9, so I can toggle the microphone with my thumb.

bindsym --border --whole-window button9 exec --no-startup-id pactl set-source-mute <MICROPHONE> 0
bindsym --border --whole-window --release button9 exec --no-startup-id pactl set-source-mute <MICROPHONE> 1

Unfortunately there is currently an unresolved issue about using --whole-window and --release together. For it to work you need to apply this patch to your i3 before compiling.

Bonus: Show microphone status with Scroll Lock led

If you use a keyboard with a scroll lock, like me, then you can misuse that led to show you the microphone status. It's mostly useless on Linux anyway.

# enable the led
xset led 3
# disable the led
xset -led 3

You can simply add that to your key bindings as well.

bindsym Mod1+space exec --no-startup-id "pactl set-source-mute <MICROPHONE> 0;xset led 3"
bindsym --release Mod1+space exec --no-startup-id "pactl set-source-mute <MICROPHONE> 1;xset -led 3"