amixer is an ALSA cli utility.
The easiest utility for configuring our sound card volumes is alsamixer, but it doesn't lend itself to scripting the way amixer does.
Recently, I read a post where the person complained that the sound settings were not being saved between reboots. I was not able to do any troubleshooting with the person. Nevertheless, I can conceive of conditions where sound settings could be changed, most likely because of other programs changing them.
The purpose of this how-to is to introduce you to a method whereby you can set and/or reset your sound settings in rc.local without having to do it manually.
For starters, your sound card volume and other settings are kept in this file: /etc/asound.state
You may need to open and read this file in order to get the numid you'll want to use in your command string for /etc/rc.d/rc.local
In this post I'll show you how to set the CD Volume to 80% on each boot. One thing I need is the 'numid' for the CD Volume. So I open /etc/asound.state in my text editor and look for it. Here it is:
Code: Select all
control.21 {
comment.access 'read write'
comment.type INTEGER
comment.count 2
comment.range '0 - 31'
iface MIXER
name 'CD Playback Volume'
value.0 21
value.1 21
}
Next I enter this command in rc.local
amixer -c 0 cset numid=21 80%
amixer is the alsa utility
-c 0 says this setting is for the first sound card
cset is an amixer agrument to be followed with strings
numid=21 says this is for the CD Volume as shown above in the code snippet. Your sound may not use the same numid for CD Volume.
80% is the volume level for all CD channels.
---------------
I don't think it very necessary to give more examples, because the same proceedure works the same on other controls.
There is however one command, which I think can be very helpful:
amixer info
Outputs this (for me)
Card default 'CK804'/'NVidia CK804 with ALC850 at irq 11'
Mixer name : 'Realtek ALC850 rev 0'
Components : 'AC97a:414c4790'
Controls : 42
Simple ctrls : 27
--------------
For additional information, I've attached amixer's man page in html format.