afduck is a simple macOS command-line tool that ducks media app audio through Shortcuts, plays two cue sounds, plays a target audio file, then plays two more cue sounds before unducking on cleanup.
afduck currently works reliably from debug builds launched with swift run. The installed standalone binary path is still blocked by macOS automation behavior around the underlying Shortcuts/SoundSource step, so the current recommended workflow is repo-local debug execution.
- macOS
- Xcode / Swift toolchain with
swiftavailable - A
duck-media-app-audioshortcut installed in Shortcuts - An
unduck-media-app-audioshortcut installed in Shortcuts
swift buildswift run afduck <path>Example:
swift run afduck ~/Music/example.wavFor repeated local use after an initial build:
swift run --skip-build afduck ~/Music/example.wav- Run the
duck-media-app-audioshortcut. - Play the system
Popsound twice. - Play the target audio file.
- Play the system
Popsound twice again. - Run the
unduck-media-app-audioshortcut during cleanup before exit.
- If the input path does not exist,
afduckexits with a validation error. - If either shortcut is missing or fails,
afduckreports the shortcut failure and exits. - If playback fails to start,
afduckreports the playback error and exits. - If the installed standalone binary fails with a generic Shortcuts error, use
swift run afduck <path>for now. A more plug-and-play app-based approach is planned forv2.0.0.
v2.0.0 is intended to move afduck toward a more proper macOS app experience with App Intents and bundled shortcut integration so people can compose their own SoundSource automations without depending on the current debug-build-only workflow.