On 21/01/2022 13.50, Adam Mizerski wrote:
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
Tried a moment ago. I get silence.
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
Thanks. At least, it runs, but I get silence. vlc runs with that, but starts a GUI, and I barely hear anything. Erebor4:~ # sudo -u cer env XDG_RUNTIME_DIR=/run/user/1000 vlc /usr/share/sounds/freedesktop/stereo/bell.oga VLC media player 3.0.16 Vetinari (revision 3.0.13-8-g41878ff4f2) [000055fb1f352e70] main interface error: no suitable interface module [000055fb1f2614e0] main libvlc error: interface "globalhotkeys,none" initialization failed [000055fb1f2614e0] main libvlc: Running vlc with the default interface. Use 'cvlc' to use vlc without interface. [000055fb1f352e70] skins2 interface error: cannot initialize OSFactory [000055fb1f352e70] [cli] lua interface: Listening on host "*console". VLC media player 3.0.16 Vetinari Command Line Interface initialized. Type `help' for help.
volume 256.0 q Shutting down. [000055fb1f352e70] [cli] lua interface: Requested shutdown. Erebor4:~ #
-- Cheers / Saludos, Carlos E. R. (from oS Leap 15.3 x86_64 (Erebor-4))