Osascript Audio

Control macOS system audio via osascript. Use when getting or setting system volume, toggling mute, listing audio input/output devices, or checking which device is the default output.

damionrashford 541602a 4 files · 7.0 KB Updated

File contents

osascript-audio

System audio control via AppleScript volume commands and system_profiler. All scripts are pure Python — no JXA needed for basic audio control.

Volume API

AppleScript volume settings returns a record with all four levels:

  • output volume — speaker/headphone volume (0–100)
  • input volume — microphone level (0–100)
  • alert volume — system alert sounds (0–100)
  • output muted — boolean

Scripts

Get current volume levels or set output volume (0–100):

uv run scripts/volume.py
uv run scripts/volume.py --set 75
uv run scripts/volume.py --set 0

Mute, unmute, or toggle output audio — --status to check current state:

uv run scripts/mute.py --toggle
uv run scripts/mute.py --on
uv run scripts/mute.py --off
uv run scripts/mute.py --status

List all audio input/output devices via system_profiler SPAudioDataType:

uv run scripts/audio-devices.py

Key AppleScript Patterns

-- get all levels
get volume settings

-- set output volume
set volume output volume 75

-- mute / unmute
set volume with output muted
set volume without output muted

damionrashford/osascript-reference/tree/main/skills/osascript-audio commit 541602ad8f

Frequently asked questions

npx skillmds@latest add damionrashford/osascript-audio