# Owner: glow # KeyID: E65A8520F36AEE13CFE4F56BEB8FE331063A4794 # Key: https://glow.li/pgp # Verify: curl "https://glow.li/posts/global-push-to-talk/index.html.asc" | gpg -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 +++ { "date": "2021-04-14", "layout": "post", "sharingimage": "media/videos/previews/p2t-pavucontrol", "sharingvideo": "media/videos/p2t-pavucontrol.webm", "tags": ["Technology", "Tutorial", "CLI", "Snippet"], "title": "Global push to talk with i3 and pulseaudio" } +++ 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 0 # mute pactl set-source-mute 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 0 bindsym --release Mod1+space exec --no-startup-id pactl set-source-mute 1 ``` Replace `` 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 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 0 bindsym --border --whole-window --release button9 exec --no-startup-id pactl set-source-mute 1 ``` Unfortunately there is currently an unresolved [issue](https://github.com/i3/i3/issues/3459) about using `--whole-window` and `--release` together. For it to work you need to apply [this patch](https://github.com/i3/i3/issues/3459#issuecomment-430597197) 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 0;xset led 3" bindsym --release Mod1+space exec --no-startup-id "pactl set-source-mute 1;xset -led 3" ``` -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEE5lqFIPNq7hPP5PVr64/jMQY6R5QFAmRuqFMACgkQ64/jMQY6 R5QMIRAAoRGaANse31voMVl4P8cc/yZs/tVTMYsc6Q+n0jPd05Zz0ZTc1aRL4H3Z VVyDbSbul2iGqYNCOA/uIH5AJDkpAQLVvUJxNPtBcGcE5fa9IAE3VuBTcy5DnjfE x3Tl+JEBIpcclUVZYHrVRhdVFsG8Lc3DOSFpQ2NOKIxb/ziufupr8tOUlKA0Vzf9 PxUHjNYnmio1UpWNPzRTsi/sjlyzB7JqBThhL4SbN/QA7Uijv3jzw5YqhgvMGjxP DKphX5E9MmY8HFFoQM1qh/J4n/m8Df41ZWnUIrl7aJLEEiSTPZdr592dvF2r1D2C yk/H00u7hTSNpmMPmiNo8wqQ2m8MNEcX5pre/LVrZJ+Lk0AfcHhxPvv8K0MCgKzL TjEVCmu7MjT1d9YAetENE3rPsA0qU0HhpUGk8JZoz+q/+8lkvWD+gn6Hmm8iIqw/ s5Rqr+f9T0thld2TAF8niq/MRarIVq5rceO7OsbLKunF2xeTHD270YxoHG/Esi/h NOxTp0fX7CqRX4q94LSAn8SlIxsl2wRUZlrVxohLcW0zvmpYnqIyXPtN6Laf0QPG pacBwxl/BUvJhQ3N+4eIbadampC32M8FH5QmaVHEZsZG9Q+p2fHudHIAFVLlB+n1 SPqTzoTx+NaFfje/HqDcnna70nFZBT2/qIcO2qPF8cZVsWI5B2c= =jSUn -----END PGP SIGNATURE-----