Skip to content

Silently mute the mic input via AppleScript

Note: The scripts in this hint don't truly mute the mic input; they drop its volume to zero. That's because there's no way to mute an input source via AppleScript (while you can mute an output source). At zero level, the mic will still pick up sounds, but they're very quiet.

Thanks to John Welch, though, you can download an app that will mute the mic with a simple one-click HUD—he posted it in the first comment here, but that download link is broken. Instead, download it via this link, and you should be good to go.

While recording our weekly podcast, The Committed, I often want to mute the microphone input for one reason or another. (Yes, my microphone has a big Mute button on it, but pressing it results in an audible CLICK in the recording.)

There are any number of ways to do this quietly, including just sliding the level down in the Sound System Preferences panel (though it's hard to then get it back to exactly the right spot). There are also any number of App Store apps that will do this for you; some are free, some are paid. And doing it programmatically yourself is as easy as two one-line AppleScripts:

Save those separately, assign keyboard shortcuts (or more quietly, trackpad gestures) using your favorite third-party tool, and you're done.

But I wanted something more. I wanted one script to mute and unmute the volume. I also wanted a visual reminder when I was muted. After an afternoon of slogging around the internet, looking up obscure AppleScript command syntax, and diving into Sal Soghoian's AppleScript 1-2-3 book, I came up with something that seems to work. This short video shows one version of it in action:

Read on for the code and a how-to on putting it to use.

There are three versions of this script. Why three? Because OS X isn't very script-friendly for certain tasks, that's why.

Version One: Static Desktop Picture

This first version works for users who do not have their desktop picture set to rotate. In that case, OS X provides a way for the script to save and restore the desktop image, so that's what it does. When muted, you'll see a lovely lavender desktop (feel free to edit the script to point to the image of your choice).

Version Two: Rotating Desktop Pictures

The second version is for those who use rotating images and want a visual reminder of when they're muted. To make this work, though, I had to rely on one of our (Many Tricks) apps—Desktop Curtain ($5; free trial). That's because when you use rotating desktop images, there's no way to save and restore the current image via AppleScript—nor is there any way to simply say "use this desktop image now." What works for static images fails completely for rotating images.

So my workaround is to show and hide the desktop (leaving the actual desktop picture unchanged) by hiding/showing Desktop Curtain's, well, curtain. This will also affect all displays, making it easy to tell you're muted. (This script should work equally well with any other desktop curtain app that lets you show and hide the curtain via a global hot key, but it'd need to be modified for that, of course.)

For this to work properly, you have to set a few prefs in Desktop Curtain:

Version Three: Volume Mute Only, No Visuals

The third version is just a simplified version of the other two scripts—it removes any visual indicator that you've muted the input volume. This means it's up to you to remember the mic's mute state, which could be tricky. With that disclaimer, here it is.

Regardless of which version of the script you choose to use, implementation is identical:

  1. Open AppleScript Editor (in Applications > Utilities).
  2. Copy the script of your choice (there's a handy copy button on the toolbar of each code section), and paste into AppleScript Editor.
  3. Save the script as a regular AppleScript (File Format: Script in the pop-up in the Save dialog), in a safe location. You won't run the script by hand, so it can be buried in some sub-folder somewhere.

With the script saved to your Mac, all that's left is figuring out how to trigger it. You could use a third-party tool to assign a keyboard shortcut, but pressing those keys will generate noise. So I prefer my touchpad, using a silent gesture to mute and unmute the mic input.

To do that, you'll need a tool that lets you assign your own gestures to the trackpad. I know there are several, but the one I use is BetterTouchTool.

I'm not going to go into a full how-to with BetterTouchTool, but here's the tl;dr version: Create a new entry in the Trackpads section, assign the gesture you'd like to use, and then set the Predefined Action pop-up to Controlling Other Applications: Open Application / File / AppleScript. When the file navigation dialog appears, navigate to the script you saved earlier, and you're done. Your mic muting/unmuting is now a quick gesture away.

Muting—and unmuting—the mic input is now a simple matter of a swipe on my trackpad.

8 thoughts on “Silently mute the mic input via AppleScript”

    1. Hey wow, somehow I missed this for an entire year — thanks! Works like a charm.

      -rob.

    2. Update: I've linked to a zipped version of just the binary in the main article now, as the Dropbox link is dead.

      -rob.

  1. While setting the input vol to 0 via applescript shows the input vol to be at 0 via the slider, the mic will still pick up sound as can be seen by making noise. The input level gauge will reflect this. If you or anyone has a fix for this I'd love to hear it. I've tried negative values with no different affect than 0.

      1. Paul - Download the app in the first comment, by John C. Welch. It works perfectly—just a big mute/unmute button.

        -rob.

  2. Francois Prowse

    Muting the mic seems to must the first mic listed...what if you have multiple microphones?

    1. Ummm ... I don't know :). That's beyond my skill level, so unfortunately, I can't be of any help.

      regards;
      -rob.

Comments are closed.