Using sudo alsamixer (a GUI interface) followed by sudo alsactl, I have been able to adjust an external USB microphone gain (volume). Whenever the USB microphone is removed, the whole procedure must be repeated. amixer is a text shell based command that has the same results as alsamixer so that I could write a shell script to execute each time the external USB microphone is plugged-in. I have read man amixer; amixer -c 1 sset Line,0 80%,40% unmute cap from man is the closest to what I need but the syntax is not that clear. I have read https://www.geeksforgeeks.org/amixer-command-in-linux-with-examples/ but that too is not that clear. I assume there is no alsamixer setting to produce the equivalent amixer command. Any assistance would be appreciated. Take care. Stay safe.
Asked
Active
Viewed 1,987 times
1 Answers
0
From:
Howto save AlsaMixer settings?
ou could also save the mixer settings into a custom file with alsactl:
alsactl --file ~/.config/asound.state store
Reloading:
alsactl --file ~/.config/asound.state restore
Note that until some posts a how-to or I can track it down, the above alsactl ... restore needs to be done each time the USB microphone is plugged into the computer. Presumably, there is some USB mounting/opening/attaching initiation configuration file to the USB function that actually identifies the USB microphone as what alsamixer claims to be a "sound card"; modifying that file should make the restore unnecessary as the fix would be permanent to the system and used for every instance of the USB microphone.

Yasha Karant
- 961
udevadm monitor environment --udev
next you can list attributes withudevadm info -a --path=
– Oct 21 '20 at 08:31/etc/udev/rules.d/99-amixer-usb-mic.rules
and run,udevadm trigger
connect your microphone again. You may need to adjust the rule to match your hardware. – Oct 22 '20 at 04:26/lib/udev/rules.d/90-alsa-restore.rules
, you can test it on the command linesudo /usr/sbin/alsactl -E HOME=/run/alsa -E XDG_RUNTIME_DIR=/run/alsa/runtime restore 0
where 0 is the card number. – Oct 22 '20 at 04:52/etc/alsa/state-daemon.conf
and restart this will change alsa's state management schemas to alsa state daemon, which pulls and saves the state periodically. (...but i have had alot of problem with this daemon) – Oct 22 '20 at 05:54