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
devicethe default for thatkind.deviceis the name as macOS lists it (case does not matter) or the device's UID.nameis another spelling ofdevice.mute, unmute and toggleMute change a device's mute switch. With a
device, that device is used. Without one, the current default forkindis 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 #
| Parameter | Type | Required | Values | What it does |
|---|---|---|---|---|
op | one of | Yes | setDefault mute unmute toggleMute | Required. setDefault, mute, unmute or toggleMute. action is another spelling. |
action | text | |||
device | text | The device's name or UID. Required for setDefault. | ||
kind | one of | output input effects | output, input or effects. Anything else fails. | |
name | text | Another spelling of device. |
Every step also accepts label, onFailure, timeout and dryRunSafe.
Examples #
- Mute the output device
- Show “Microphone muted”
Gotchas #
Fails with
audioDevice setDefault needs a device (its name or UID)whendeviceis 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
audioOutputevent to react when the output device changes.In a dry run the step is simulated and nothing is switched.