switchaudio-osx

repository·master·Indexed 23 days ago

https://github.com/deweller/switchaudio-osx

A command-line utility for macOS that allows users to switch audio input and output sources, list available devices, and control mute status without using a GUI. It provides the SwitchAudioSource command to set devices by name, ID, or UID, and supports output formats in cli, human, and json.

Tokens
569
Snippets
2
Records
5
Agent score
31%

What's inside switchaudio-osx

  1. Use SwitchAudioSource to switch audio devices

    master

    The SwitchAudioSource command allows you to switch the audio source on macOS via the command line. You can identify a device using its name (-s), its ID (-i), or its UID (-u).

    Common flags:

    • -a: Show all available devices.
    • -c: Show the currently selected device.
    • -f <format>: Set output format to cli, human, or json (defaults to human).
    • -t <type>: Set device type to input, output, or system (defaults to output).
    • -n: Cycle to the next audio device.
    • -s <device_name>: Set device by name.
    • -i <device_id>: Set device by ID.
    • -u <device_uid>: Set device by UID or a substring of the UID.
  2. Mute or unmute audio devices

    master

    You can control the mute status of audio devices using the -m flag. To target specific devices like a microphone, use the -t flag to specify the device type.

    Supported mute modes for -m:

    • mute
    • unmute
    • toggle

    Example: Toggle the mute state for the currently selected input device (e.g., a microphone):

    SwitchAudioSource -m toggle -t input
  3. SwitchAudioSource CLI reference

    master

    The following flags are available for the SwitchAudioSource command:

    FlagDescription
    -ashows all devices
    -cshows current device
    -f _format_output format (cli/human/json). Defaults to human.
    -t _type_device type (input/output/system). Defaults to output.
    -m _mute_mode_sets the mute status (mute/unmute/toggle).
    -ncycles the audio device to the next one
    -i _device_id_sets the audio device to the given device by id
    -u _device_uid_sets the audio device to the given device by uid or a substring of the uid
    -s _device_name_sets the audio device to the given device by name
  4. Execute the switchaudio-osx CLI

    master
    The switchaudio-osx command-line tool is invoked via the main entry point, which delegates execution to runAudioSwitch. This function processes command-line arguments (argc, argv) to perform audio device switching, muting, or listing operations on macOS. To use the tool, you must pass specific flags and arguments to the binary as defined in its CLI interface.