W dniu 21.01.2022 o 13:21, Carlos E. R. pisze:
Hi,
I want to play a sound from a script, for example to signal it finished, but I can't.
First problem: I can't find a CLI command able to play the sound files I want, found in the default installed system:
aplay and paplay seem to use some low-level raw audio formats. I suggest using gstreamer: gst-play-1.0 /usr/share/sounds/freedesktop/stereo/bell.oga
Second problem: I can not play them as root, and I do need them as rootm because those scripts run as root.
That's a much more difficult, than it seems. Pulseaudio is running as a user you're logged in. The integration with logind and udev allows to give access to soundcard to current active user. If you're running your script as root, you can use sudo to play the sound as your user. I found this works: sudo -u etam env XDG_RUNTIME_DIR=/run/user/1000 gst-play-1.0 /usr/share/sounds/freedesktop/stereo/bell.oga