Sponsors

Apple Store

Visit the official Apple Store to buy a Mac online. Free shipping!



Editors' Picks


Comments

Contact Us

Search

Top Posts

Categories

Recent Posts

Our Feeds


Change the system volume from the command line

There are several ways to go about changing the volume on your Mac, but did you know you can use the command line? I’m a big command line junkie so the more things I can do from the Terminal the better. Without further ado, here’s the necessary commands:
Mute your Mac: sudo osascript -e "set Volume 0"
Maximum volume: sudo osascript -e "set Volume 10"
Both of these commands will ask for your root password because of the usage of ’sudo’ which runs the osascript command as the administrator. As you may have guessed, you can fill in other numbers in place of 0 and 10 for other sound levels. Enjoy!

Digg!


Social bookmarks:


Comments:

Comments: 10

Comment from Andrew
Time: April 28, 2007, 7:32 am

Two things:

You shouldn’t need to use sudo. “osascript -e ’set Volume 5′” works fine for me in a non-admin account.

And you aren’t limited to integers: “osascript -e ’set Volume 4.5′” also works, so you could ramp the volume up or down slowly with a script…

Comment from Weaver
Time: April 28, 2007, 10:37 am

what I don’t understand about osascript is that it’s just a command line tool to run apple scripts, so it’s weird to me that it can be used for other things like this.

very useful eithreway

Comment from Jerrome
Time: May 3, 2007, 2:08 am

True, osascript is the command line tool to run apple scripts. In fact it does nothing different here, it runs an apple script to set the volume.

Comment from Kevin
Time: May 14, 2007, 8:11 am

Two things:

1. Like Andrew, I didn’t need sudo permissions for this. 10.4. YMMV.
2. I found it fun to combine this with a few other commands.
a. SSH into a coworker’s box.
b. # osascript -e “set Volume 10″
c. # say -v Whisper “Why are you checking personal email on company time?”

It gets interesting results. ;)

Comment from Jay Valambhia
Time: November 15, 2007, 4:27 am

Why bother with osascript with scutil and diskutil commands work a charm.

Just type the following:

Set Bonjour Name
sudo scutil –set LocalHostName volume_name

Set Sharing Name
sudo scutil –set ComputerName volume_name

Set Hard Disk Name
diskutil rename /Volumes/ volume_name

Smoother and effiicient.

Jay

Comment from clitor
Time: January 12, 2008, 3:28 pm

excellent comands

Comment from shaun
Time: February 4, 2008, 8:50 pm

Just want to point out that the “set volume x” is deprecated… Instead use

$ osascript -e “set volume output volume 100″

or any value between 0 and 100

Comment from Amos
Time: February 5, 2008, 6:23 pm

Max volume actually appears to be 7. At least, if you work your way down from 10, 6 is the first one that is less on the displayed volume graphic.

Comment from tim
Time: April 2, 2008, 10:13 am

Is there a way to run the volume command at shutdown? I don’t always remember to mute before shutting down. Being a student sometimes in class or a library the start up sound can be annoying.

Write a comment





April 28th, 2007