Files
README.md

audio-toggle #

A small macOS command-line tool that switches the default audio output between two devices: Scarlett 8i6 USB and miniDSP 2x4HD.

The tool uses CoreAudio directly. It has no dependencies other than the Swift compiler that comes with the Xcode Command Line Tools.

Behavior #

  • If the current output is Scarlett 8i6 USB, the tool switches to miniDSP 2x4HD.
  • If the current output is a different device, the tool switches to Scarlett 8i6 USB.
  • The tool sets the default output and the system output (alerts and sound effects) to the same device.
  • The tool does not change the default input device.

Build #

Compile the tool into a directory on your PATH:

swiftc -O -o ~/.local/bin/audio-toggle main.swift

Usage #

audio-toggle                 # toggle between the two devices
audio-toggle "BlackHole 2ch" # switch to an output device by its exact name
audio-toggle --list          # list output devices (* = current default)

Change the devices #

The two device names are the constants deviceA and deviceB at the top of main.swift. To get the exact names, run audio-toggle --list. After you change the constants, build the tool again.

Raycast #

To run the tool from a Raycast hotkey, put this Script Command in a Raycast Script Directory:

#!/bin/bash

# @raycast.schemaVersion 1
# @raycast.title Toggle Audio Output
# @raycast.mode silent
# @raycast.icon 🔊

exec "$HOME/.local/bin/audio-toggle"

To add the directory, open Raycast Settings, then go to Script Commands → Add Script Directory. To set a hotkey, find the command in Raycast, press ⌘K, and select Configure Command → Record Hotkey.