Skip to content

Instantly share code, notes, and snippets.

@Vftdan
Forked from nikhilw/toggleMicOneLiner.sh
Last active January 7, 2019 13:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Vftdan/8db21e38d5f626f8abae2e43e521c8bb to your computer and use it in GitHub Desktop.
Save Vftdan/8db21e38d5f626f8abae2e43e521c8bb to your computer and use it in GitHub Desktop.
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