在 Mac 命令行静音或调节音量

AppleScript 的 set volume 是 macOS 内置的唯一命令行静音/调音量方式,适合脚本和快捷指令。

macOSosascript AppleScript自动化卷低风险
运行 `osascript -e "set volume output muted true"` 静音;false 解除静音,`set volume output volume 50` 设置百分比音量。

01命令

命令
$ osascript -e "set volume output muted true"

02作用说明

macOS 没有专门的音量命令行工具,通用做法是通过 osascript 执行一行 AppleScript。set volume 支持 output muted true/false、output volume 0–100,以及麦克风输入的 input volume。注意一个不对称设计:输出音量是 0–100 的百分比,而输入音量是 0–255,脚本中经常在这里踩坑。配合 cron 或快捷指令可以在指定时间自动静音。

03风险

风险低风险
使用条件Built-in on macOS.

04撤销

撤销
$ osascript -e "set volume output muted false"

05来源

最后验证: 2026-09-17 · 分类: 媒体