Is it possible to set the audio volume using the terminal instead of clicking the speaker icon in the top bar?
The reason I want to do this is that my keyboard does not have volume increase/decrease buttons and I find it annoying to reach for the mouse.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
For interactive usage you can use alsamixer. For scripting (e.g. binding to key combinations) take a look at amixer.
alsamixer is included by default in most systems.
To set the master volume use:
# Gets a list of simple mixer controls $ amixer scontrols
Then set it to the desired volume, as an example
$ amixer sset 'Master' 50%
Method 2
Found in Openbox’s configuration file rc.xml:
# increase by 3% amixer -q sset Master 3%+ # decrease by 3% amixer -q sset Master 3%- # mute/unmute amixer -q sset Master toggle
amixer manual page can give more details.
Method 3
If your system is using pulseaudio you could use pactl:
pactl set-sink-volume 0 +15%
or
pactl set-sink-volume 0 -5dB
though you could also specify an integer or a linear factor:
set-sink-volume SINK VOLUME [VOLUME ...]
Set the volume of the specified sink (identified by its symbolic name or numerical index). VOLUME can be speci‐
fied as an integer (e.g. 2000, 16384), a linear factor (e.g. 0.4, 1.100), a percentage (e.g. 10%, 100%) or a
decibel value (e.g. 0dB, 20dB). If the volume specification start with a + or - the volume adjustment will be
relative to the current sink volume. A single volume value affects all channels; if multiple volume values are
given their number has to match the sink's number of channels.
Method 4
I know this is an old one. Since Alsa and pulseaudio are so connected, this answer from askubuntu helped me manage the volume from both my main sound and the HDMI:
increase volume
amixer -q -D pulse sset Master 10%+
decrease volume
amixer -q -D pulse sset Master 10%-
toggle mute
amixer -q -D pulse sset Master toggle
Other amixer sset commands work too.
Method 5
These are “more natural for human ear”.
To get the master in the alsamixer units, use:
amixer -M get Master
To raise the volume by 5% in the alsamixer units, for example:
amixer -M set Master 5%+
https://bbs.archlinux.org/viewtopic.php?id=135348
Method 6
you can also try pamixer, a recent project that does exactly what you want. It is in the ArchLinux AUR repository with the same name.
Method 7
In OS X use the following:
# highest osascript -e "set Volume 7" # lowest osascript -e "set Volume 1" # middle osascript -e "set Volume 3.5"
You can even set the volume to other fractional levels:
# 25% osascript -e "set Volume 1.75"
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0