How do I play sound when running an application as another user on Ubuntu 17.10? I'm using Gnome Shell on X.Org (I also have LXDE/Openbox but I mainly use Gnome Shell).
Here's what I've done so far. :
In terminal, I used:
sudo usermod -G group -a account
to add account in question to the following groups: audio, pulse and pulse-access
Every time I launch an App via the account (let's say firefox), I do
xhost +local:account;sudo -u account -H firefox
When Firefox launches, I take it to Youtube to test the sound and I get a message that pulseaudio was not detected. When I log out and log back into the other user via GDM, no sound issues arise and everything works as it should.
Can anyone see anything I'm doing wrong or suggest a possible solution?
UPDATE: The purpose of this exercise was to sandbox untrusted apps into restricted accounts rather than give them free rain of my home directory. I have learned of some massive security flaws in X11 that makes opening a concurrent session via the xhost command undesirable. If you are curious to learn more about Xorg's weaknesses, you can read these articles:
Your Linux PC isn't as secure as you think it is
Ubuntu’s Snap packages aren’t yet as secure as Canonical’s marketing claims <- this applies to snap under X11 (not Wayland) The Turla espionage operation also infected Linux systems with malware
These issues have rendered the question of running audio under a concurrent session irrelevant to me as I no longer desire to run concurrent sessions for the above mentioned reasons.