[BUGFIX] alsamixer & alsactl per session behaviour inconsistency
by H1p8r10n from LinuxQuestions.org on (#4V79K)
Hi,
How can an unprivileged user save alsa mixer settings for his/her own session ? He/she can't !!
-> alsactl can NOT run as unprivileged user cause no write access to /var/lib/alsa/asound.state :
Code: hyperion@darkstar:~/Desktop$ /usr/sbin/alsactl store
/usr/sbin/alsactl: save_state:1626: Cannot open /var/lib/alsa/asound.state for writing: Permission denied -> but at the same time : alsamixer can NOT be used as root in a terminal (unless launched in a whole root desktop session along with pulseaudio, which is bad), it has to be launched as unprivileged user (a paradox bug) :
Code: root@darkstar:~# alsamixer
ALSA lib pulse.c:242:(pulse_connect) PulseAudio: Unable to connect: Connection refused
cannot open mixer: Connection refused -> The FIX :
Add run-able /usr/bin/alsactl containing :
Code: #!/bin/bash
[ $UID != 0 ] && /usr/sbin/alsactl --file ~/.config/asound.state "$@" || /usr/sbin/alsactl "$@"
Optionally, provide a way for the user to "auto restore" mixers at session startup :
Add run-able /etc/xdg/autostart/alsamixer-restore.desktop containing :
Code: [Desktop Entry]
Version=1.0
Name=Alsamixer session restore
Comment=Restore alsamixer settings for the current session
Exec=alsactl restore
Icon=volume-soundsettings
Terminal=false
Type=Application
X-GNOME-Autostart-Phase=Initialization
X-KDE-autostart-phase=1 All the best
JP


How can an unprivileged user save alsa mixer settings for his/her own session ? He/she can't !!
-> alsactl can NOT run as unprivileged user cause no write access to /var/lib/alsa/asound.state :
Code: hyperion@darkstar:~/Desktop$ /usr/sbin/alsactl store
/usr/sbin/alsactl: save_state:1626: Cannot open /var/lib/alsa/asound.state for writing: Permission denied -> but at the same time : alsamixer can NOT be used as root in a terminal (unless launched in a whole root desktop session along with pulseaudio, which is bad), it has to be launched as unprivileged user (a paradox bug) :
Code: root@darkstar:~# alsamixer
ALSA lib pulse.c:242:(pulse_connect) PulseAudio: Unable to connect: Connection refused
cannot open mixer: Connection refused -> The FIX :
Add run-able /usr/bin/alsactl containing :
Code: #!/bin/bash
[ $UID != 0 ] && /usr/sbin/alsactl --file ~/.config/asound.state "$@" || /usr/sbin/alsactl "$@"
Optionally, provide a way for the user to "auto restore" mixers at session startup :
Add run-able /etc/xdg/autostart/alsamixer-restore.desktop containing :
Code: [Desktop Entry]
Version=1.0
Name=Alsamixer session restore
Comment=Restore alsamixer settings for the current session
Exec=alsactl restore
Icon=volume-soundsettings
Terminal=false
Type=Application
X-GNOME-Autostart-Phase=Initialization
X-KDE-autostart-phase=1 All the best
JP