Browse the docs

Switch audio device

Switches the default sound output, input or effects device, or mutes one.

Switch audio kind to device

Keyboard Maestro: SetAudioDevice, MuteAudioDevice

Details #

Works with the Mac's audio devices through CoreAudio. kind says which role: output (the default), input or effects (where alert sounds play).

op chooses the action:

  • setDefault makes device the default for that kind. device is the name as macOS lists it (case does not matter) or the device's UID. name is another spelling of device.

  • mute, unmute and toggleMute change a device's mute switch. With a device, that device is used. Without one, the current default for kind is used.

The output is the device's name for setDefault, and true or false (muted) for the mute operations. The Trace note says which device it was.

Parameters #

ParameterTypeRequiredValuesWhat it does
opone ofYessetDefault mute unmute toggleMuteRequired. setDefault, mute, unmute or toggleMute. action is another spelling.
actiontext
devicetextThe device's name or UID. Required for setDefault.
kindone ofoutput input effectsoutput, input or effects. Anything else fails.
nametextAnother spelling of device.

Every step also accepts label, onFailure, timeout and dryRunSafe.

Examples #

Mute the microphone (dry run only simulates it)
Do
  1. Mute the output device
  2. Show “Microphone muted”
Open in Switchboard to try it

Gotchas #

  • Fails with audioDevice setDefault needs a device (its name or UID) when device is missing.

  • A name that matches nothing fails and lists the devices it did find, for example no output audio device called "X"; the devices are .... The match is by exact name or UID, not partly.

  • Muting uses the device's own mute switch. A device that has none fails with <name> can't be muted (it has no mute control).

  • Pair this with the System event audioOutput event to react when the output device changes.

  • In a dry run the step is simulated and nothing is switched.

See also #

System volume, System event