Skip to content

Instantly share code, notes, and snippets.

@kxalex
Last active February 16, 2021 08:06
Show Gist options
  • Save kxalex/396981adbe978db6da9937d308c2349c to your computer and use it in GitHub Desktop.
Save kxalex/396981adbe978db6da9937d308c2349c to your computer and use it in GitHub Desktop.
AppleScript to choose input device (i.e. microphone)
# Install SwitchAudioSource tool to make this script work
# brew install switchaudio-osx
# I assigned fn^⌥⌘M hotkey (using BetterTouchTool) to have quick access to input devices
set theInputDevices to paragraphs of (do shell script "/usr/local/bin/switchaudiosource -t input -a | sed -E 's/(.*)\\ \\(input\\)/\\1/'")
set theCurrentDevice to do shell script "/usr/local/bin/switchaudiosource -t input -c"
set theInput to choose from list theInputDevices with prompt "Select Input Device:" default items {theCurrentDevice}
if theInput = false then return
do shell script "/usr/local/bin/switchaudiosource -t input -s '" & theInput & "'"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment