Skip to content

Instantly share code, notes, and snippets.

@krisleech
Created January 11, 2020 15:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save krisleech/9be17a3f79f692b08c34c986cab4d368 to your computer and use it in GitHub Desktop.
Save krisleech/9be17a3f79f692b08c34c986cab4d368 to your computer and use it in GitHub Desktop.
Push to Speak, via command line

This works for all mics including webcam mics.

bin/mic-on

#!/usr/bin/env bash

# toggle webcam mic
amixer -c 1 sset Mic cap
# toggle default mic
pactl set-source-mute @DEFAULT_SOURCE@ off
notify-send "Listening"

bin/mic-off

#!/usr/bin/env bash

# toggle webcam mic
amixer -c 1 sset Mic nocap
# toggle default mic
pactl set-source-mute @DEFAULT_SOURCE@ on
notify-send "Muted"

bin/toggle-mics

#!/usr/bin/env bash

# toggle webcam mic
amixer -c 1 sset Mic toggle
# toggle default mic
pactl set-source-mute @DEFAULT_SOURCE@ toggle
amixer get Capture | grep '\[off\]' && notify-send -a "Microphone" "OFF" || notify-send -a "Microphone" "ON"

i3 configuration to bind to keys

# Media
bindsym XF86AudioMute exec pactl set-sink-mute @DEFAULT_SINK@ toggle # mute sound
bindsym XF86AudioLowerVolume exec pactl set-sink-volume @DEFAULT_SINK@  -5% #decrease sound volume
bindsym XF86AudioRaiseVolume exec pactl set-sink-volume @DEFAULT_SINK@ +5% #increase sound volume
bindsym XF86AudioMicMute exec ~/bin/toggle-mics

# Push to speak
bindsym --release Menu exec ~/bin/mic-off
bindsym Menu exec ~/bin/mic-on

bindsym F1 exec pactl set-sink-mute @DEFAULT_SINK@ toggle # mute sound
bindsym F2 exec pactl set-sink-volume @DEFAULT_SINK@  -5% #decrease sound volume
bindsym F3 exec pactl set-sink-volume @DEFAULT_SINK@ +5% #increase sound volume
bindsym F4 exec ~/bin/toggle-mics
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment