I have developed a console application in .net 6 which uses a library that needs direct access to the gpio-pins of the Pi.
The Pi is running the latest Pi OS Lite x64.
Edit: This is the library requiring root: https://github.com/hzeller/rpi-rgb-led-matrix
I need to start it with sudo to gain full performance (it's a program to display videos on an LED RGB-Matrix).
The application uses libvlc to play videos which works without a problem.
Now I want to also hear the sound of the videos, so I installed an USB-Soundcard and PulseAudio using this tutorial: How do I run PulseAudio in a headless server installation?
This works as long as I run my program NOT with sudo. As soon as I start it with sudo, I get
Failed to create secure directory (/root/.config/pulse): Permission denied Failed to load cookie file from cookie: Permission denied
The last 6 hours I tried everything, from changing permissions of the folder, so user root as full access to adding a systemd-service and copying config-files from here to there... Now even the installation under the user "pi" is broken and all I get is
No PulseAudio daemon running, or not running as session daemon.
even after reinstalling using above mentioned tutorial.
I'm not a linux-guy and find it extremly complicated for such an easy thing to get it to work.
Finally I want to run my application as systemd and have the audio-output working.
Here are all the tutorials and hints I have tried, none of them worked:
- https://askubuntu.com/questions/28176/how-do-i-run-pulseaudio-in-a-headless-server-installation
- https://askubuntu.com/questions/939144/playing-audio-stops-in-unity-when-i-switch-user/939338#939338
- https://unix.stackexchange.com/questions/89977/pulseaudio-failed-to-create-secure-directory-in-nfs-share
- https://stackoverflow.com/questions/66775654/how-can-i-make-pulseaudio-run-as-root
- https://forums.fedoraforum.org/showthread.php?328238-Pulseaudio-or-Pipewire-on-boot-when-logging-as-root
- https://unix.stackexchange.com/questions/125546/how-to-run-vlc-player-in-root
- https://stackoverflow.com/questions/70706593/ubuntu-set-pulse-audio-sink-for-another-user
- https://unix.stackexchange.com/questions/338687/pulseaudio-as-system-wide-systemd-service
I'm running the latest Pi Os (x64) on a Pi 4.