Is there any way to save alsamixer settings other than alsactl store?

The root problem: for some reason, on boot, Ubuntu 14.04 disables (mutes) the S/PDIF output on my sound card.

This question and its answers indicate that sudo alsactl store will store the alsamixer settings once I've unmuted the S/PDIF output, but on boot, the S/PDIF output is muted again.

In /var/lib/alsa/asound.state (pastebin) there is one PDIF entry, which I've set to "true" and saved; this has resulted in solving auto-mute for my "Phantom Jack" but there's no other entry for the "true" S/PDIF in asound.state that I can manually adjust.

There's also an empty /var/lib/alsa/asound.state.lock file (11 bytes, blank in gedit) in the /alsa/ directory. Is this something I should be dealing with?


I have the same problem on my pc:
It appears that effectively alsa restores SPDIF "unmuted" state during boot, but then pulseaudio mutes it when user session starts.
To verify that alsa restore is ok, just run sudo alsactl restore in a terminal and look if it unmute SPDIF.
To verify that pulseaudio is the problem , just run pulseaudio -k to relaunch pulseaudio : you should see that SPDIF is muted.

As I don't know how to set pulseaudio for not muting, this is a workaround inspired from there :

  • Try if this command unmutes SPDIF channel:
    amixer set IEC958 unmute
  • If yes, create .unmute hidden file :
    gedit .unmute
    paste 4 lines in it:

    #!/bin/bash
    sleep 10 
    /usr/bin/amixer set IEC958 unmute 
    exit
    

save and close.
Now, edit .profile file :
gedit .profile
add this line at the end:

bash .unmute &

save and close.

Now test reopening session or rebooting .

Note: in the above link from Mageia, they use /etc/rc.local to run alsactl restore at boot time , it is also ok. But using .profile and amixer, no need to "sudo" and it will unmute at every session start for your login.


I adapted @laugeo's answer to fix the problem with my headphones.

The problem was that the headphone was set to unmute but it was on 00 volume.

I wanted it to be 100, so I added this: /usr/bin/amixer -c 0 set Headphone playback 100% unmute

And the .unmute script looks like:

#!/bin/bash
sleep 10 
/usr/bin/amixer -c 0 set Headphone playback 100% unmute
exit

If you want to unmute and set volume to 100% just change the channel. For example for master channel:

#!/bin/bash
sleep 10 
/usr/bin/amixer -c 0 set Master playback 100% unmute
exit