I'm using Linux Mint Cinnamon 22.3 64-bit with a Creative Sound Blaster AE-7. After booting, the card often selects the wrong output, so I currently have to open alsamixer and change it manually. My current sequence is to open a terminal, run alsamixer, press F6, select "default:0 HDA Creative," move across to "," switch it from Headphones to Speakers, press Escape, and close the terminal. What would be the proper way to automate this at login or startup? I'd prefer a reliable configuration or command-based solution rather than simulating key presses.
3 Answers
You probably shouldn’t automate the interactive alsamixer keystrokes. Set the mixer to the desired state once, then try saving it with `sudo alsactl store`. The saved state is normally written to `/etc/asound.state` and restored when ALSA initializes. If that doesn’t happen automatically, a small user autostart entry or service can run the restore command after login.
Another option is to configure the default PCM and control devices in an ALSA configuration file such as `/etc/asound.conf`. That can be more dependable than moving through alsamixer with simulated keyboard input. If the problem is actually caused by the desktop audio layer changing the device after login, you may need to configure the preferred output there as well.
I may have tried a configuration file before, but the change seemed to toggle briefly and then switch back. I also ran into system stability problems and reinstalled, so I’m looking for a careful, reliable approach.
If you absolutely need a script, write a shell script that uses the non-interactive ALSA commands for the specific control rather than launching a terminal and sending key presses. First identify the exact control name with `amixer -c 0`, then use `amixer` or `alsactl` to set that control. Test the command manually before adding it to desktop autostart; system startup can run before the user audio session is ready.

I tried saving the mixer state several times, but it still reverted after reboot. It seems another audio component may be applying its own defaults afterward.