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:

I'm running the latest Pi Os (x64) on a Pi 4.

  • I cannot comment on PulseAudio but running any user program as root is inadvisable. There should be no need to run a program as root to access GPIO. The problem may be with the GPIO library you are using or your program but as you have omitted any details no one can suggest a solution.
    – Milliways
    Commented May 28, 2023 at 23:20
  • your post is an XY question ... asking for help with what you perceive to be the solution to a problem, instead of asking for help with the problem ... in this case your solution is very misguided
    – jsotola
    Commented May 29, 2023 at 0:12
  • Just updated my question. The library states it requires root for generating hardware pin-pulses.
    – Jan
    Commented May 29, 2023 at 7:26
  • @Milliways I have no control over the library and cannot use it without root so there has to be a way to run PulseAudio as root. Security is not a concern here. Maybe I could run my entire app under the root user and don't need a sudo?
    – Jan
    Commented May 29, 2023 at 7:32


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.