I’ve been trying to solve this problem for a long while and never figured it out — even after reading lots of posts with the correct solution.
Now that I’ve finally figured it out, I’m writing it down here so I can find the solution later. (And maybe it’ll help someone else…)
Using audio on Linux with multiple simultaneous users
Wait… What? Why?
My typical usage of my Linux desktop is single user. Your usage is likely the same. Why would you even want to use multiple users at the same time?
There are a number of reasons you might want to do this, but I often test software on my machine without using a container or a VM. I do this by creating a new user account and either using su
or ssh
to switch users.
This post details the basics on how to do this.
But here are the real details with emphasis on the part I missed:
In /etc/pulse/default.pa find a line that says load-module module-native-protocol-unix
On my machine, this line is part of a block that looks like this:
### Load several protocols .ifexists module-esound-protocol-unix.so load-module module-esound-protocol-unix .endif load-module module-native-protocol-unix
Change that line to say: load-module module-native-protocol-unix auth-anonymous=1 socket=/tmp/pulse-socket
It should now look like this:
### Load several protocols .ifexists module-esound-protocol-unix.so load-module module-esound-protocol-unix .endif load-module module-native-protocol-unix auth-anonymous=1 socket=/tmp/pulse-socket
Now edit /etc/pulse/client.conf and add this line: default-server = unix:/tmp/pulse-socket
The above steps will make pulseaudio multiuser, but will ALSO have the effect of stopping pulseaudio from starting correctly. Now we need to fix that.
Create a new file called ~/.config/autostart/pulseaudio.desktop and insert:
[Desktop Entry] Version=1.0 Name=PulseAudio GenericName=Soundi Server Comment=Start the Sound Server Exec=pulseaudio -D Terminal=false Type=Application
You should restart pulseaudio after these changes. The easiest way is to log out and log back in. (But you can also kill the process by running pulseaudio --kill; pulseaudio -D
Thanks, I finally managed to make it work thanks to you.
I’ll make a summary post on the gentoo forums quoting your page, if you don’t mind.
Hi ExpoBi,
Absolutely! I’m glad my post helped someone else. 🙂