Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Toggle mic on-off on a Ubuntu / Linux Mint machine with a keyboard shortcut
#! /bin/sh
# static icon, easier to set as a bash alias or directly use as a single command instead of creating a script file.
amixer -D pulse set Capture toggle | gawk 'match($0, /(Front Left|Mono).*\[(.*)\]/, a) {print a[2]}' | xargs notify-send --hint=int:transient:1 -i "audio-input-microphone" "Mic switched: $1"
#! /bin/sh
# With icon indicating the state of the mic
state=`amixer -D pulse set Capture toggle | gawk 'match($0, /(Front Left|Mono).*\[(.*)\]/, a) {print a[2]}'`
if [ "$state" = "off" ]; then
icon="audio-input-microphone-muted-symbolic"
else
icon="audio-input-microphone-symbolic"
fi
notify-send --hint=int:transient:1 -i $icon "Mic switched: $state"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.