I'd like to add a script to startup which would allow only one application (RadioTray) to play sound and mute all other sounds.
(It's for a sort of kiosk setup.)
Is it possible?
TIA
Bash sound question...
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Bash sound question...
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Re: Bash sound question...
Not nicely. It is possible to script around
pactl list sink-inputs
once applications are in fact up and running but I can not see a way to mute/deny any beforehand; to set a Pulseaudio sink "to exclusive mode" if you will. Certainly the most intrinsic quality of Pulseaudio is being as opaque as possible for open source so I'll not guarantee this to mean that indeed you can't, but... What does immediately come to mind is foregoing Pulseaudio and having Radio Tray use ALSA; more specifically a non-mixing ALSA device so as to give it exclusive access to the sound device; to deny any subsequent opens. Unfortunately this is also not completely straightforward though: Radio Tray does not allow configuration; uses the GStreamer framework which unless instructed otherwise automatically selects "an appropriate audio sink" which on Mint ends up being Pulseaudio.
Now, given that Radio Tray is a Python application, not allowing configuration is of course somewhat relative. Referring specifically to the version of Radio Tray available from the Ubuntu 18.04/Mint 19 repositories,
sudo apt-get install radiotray
, you can change things through:Code: Select all
--- /usr/lib/python2.7/dist-packages/radiotray/AudioPlayerGStreamer.py.orig 2018-09-30 23:10:07.460210693 +0200
+++ /usr/lib/python2.7/dist-packages/radiotray/AudioPlayerGStreamer.py 2018-09-30 23:10:07.460210693 +0200
@@ -60,6 +60,10 @@
fakesink = Gst.ElementFactory.make("fakesink", "fakesink")
self.player.set_property("video-sink", fakesink)
+ alsasink = Gst.ElementFactory.make("alsasink", "alsasink")
+ alsasink.set_property("device", "hw:0")
+ self.player.set_property("audio-sink", alsasink)
+
#buffer size
if(cfg_provider._settingExists("buffer_size")):
bufferSize = int(cfg_provider.getConfigValue("buffer_size"))
Code: Select all
pacmd list-sinks | sed -n '/\s*\* index:/,/\s*index:/ { /device\.string\s*=/s/.*=\s*//p }'
aplay -L
.If you after the change fire up Radio Tray and set it playing indeed something like Rhythmbox will be unable to open the audio device so... well, sort of does what you want, even if in rather icky manner. Personally I'd at this point decide to have researched it to be "impossible" but YMMV...
Re: Bash sound question...
Thank you VERY much!
I'll try.
I'll try.