![Mac Volume](https://i-blog.csdnimg.cn/blog_migrate/65c1fd700dc77aaccb1d6d7e445052d2.png)
Oftentimes the awesome GUI applications we love are simply gloss over a command line functionality. While I do love a visual app, it's always good to know how to do things from command line, if only for the sake of automation. I've covered loads of command line secrets, most notably Mac Camera Access, so I wanted to figure out if I could control volume from command line.
通常,我们喜欢的超棒GUI应用程序只是掩盖了命令行功能。 虽然我确实喜欢视觉应用程序,但最好只是从自动化的角度出发,知道如何从命令行执行操作。 我已经介绍了许多命令行机密 ,尤其是Mac Camera Access ,因此我想弄清楚是否可以从命令行控制音量。
更改Mac系统音量 (Change Mac System Volume)
The secret to changing Mac system volume from command line is through osascript
:
从命令行更改Mac系统音量的秘诀是通过osascript
:
# Max volume
sudo osascript -e "set Volume 10"
# Mute
sudo osascript -e "set Volume 0"
# 50% volume
sudo osascript -e "set Volume 5"
Values range from 0
(muted) to 10
(maximum volume). Note that you don't get to see a nice volume change indicator -- the volume simply changes without any feedback.
值的范围从0
(静音)到10
(最大音量)。 请注意,您不会看到一个不错的音量更改指示器-音量只是更改而没有任何反馈。