Adjust Volume in Linux with Alsamixer
Set volume on the commandline in Linux. Dreams fulfilled.
Is this your tool?
First, do you have Alsamixer? It depends on your audio drivers. See those drivers with:
pactl list
You'll see lots of stuff like:
Name: alsa_output.pci-0000_00_1f.3.analog-stereo
Description: Built-in Audio Analog Stereo
Or just try by typing amixer
and get:
Simple mixer control 'Master',0
Capabilities: pvolume pswitch pswitch-joined
Playback channels: Front Left - Front Right
Limits: Playback 0 - 65536
Mono:
Front Left: Playback 19661 [30%] [on]
Front Right: Playback 19661 [30%] [on]
Simple mixer control 'Capture',0
Capabilities: cvolume cswitch cswitch-joined
Capture channels: Front Left - Front Right
Limits: Capture 0 - 65536
Front Left: Capture 65536 [100%] [on]
Front Right: Capture 65536 [100%] [on]
There's your "Master"
control. Time to drop a beat...
Adjust Volume
amixer
will let you run commands to adjust the volume. -D
identifies the device. "pulse"
works for me. I found it in another example. Why is that the proper value? Help me, Obee-doob Badoobi.
Well here are the helpful commands:
Mute
amixer -D pulse sset Master mute
Unmute
amixer -D pulse sset Master unmute
Set Volume
amixer -D pulse sset Master 0% # lowest
amixer -D pulse sset Master 100% # highest
Increase Volume
amixer -D pulse sset Master 5%+
Decrease Volume
amixer -D pulse sset Master 5%-
Read Current Volume Level
If you want to see the volume level from terminal, you can use amixer
, combined with some unix utils:
awk -F"[][]" '/Left:/ { print $2 }' <(amixer sget Master)