[GLLUG] How can I find out if external audio is connected?

Damion Yates damion.yates at gmail.com
Sat Jan 7 13:46:58 UTC 2023

On Sat, 7 Jan 2023 at 13:29, damion.yates--- via GLLUG <
gllug at mailman.lug.org.uk> wrote:

> On Mon, 26 Sep 2022, Dr. Axel Stammler via GLLUG wrote:
> > I would like to remind myself of external amplifiers uselessly running
> so I
> > would like to play a short sound signal once in a while if there is no
> audio
> > playing. OTOH, the signal should obviously not be played over the
> built-in
> > speakers. So, how can I find out (preferably using a command-line
> utility in
> > a script) which of the ‘audio out’ connectors are actually connected to
> > anything (or just have a plug in them) and if anything is played over
> these
> > connections?
> I'm not sure if it's possible to programmatically determine external vs
> built
> in, but if you're not opposed to simply hard wiring this in a cron job you
> set
> up yourself, then you can just look up up the devices with `pactl info`
> you'll
> need to has this through some perl or something and then grep out the
> local
> device leaving you with the various attached external audio devices before
> using something like aplay just send audio.

Erg, that'll teach me to use voice input on my phone.  You'll need to
"parse" or "pass"
this through a perl/sed/etc script (not "has this through some perl").

It seems to be `pw-cli ls` on systems that have moved to pipewire

> This assumes ALSA and pulseaudio
> which is reasonably likely but audio in Linux changed over many years so
> you
> might have Oss or you might be using pipewire etc etc.  Determining if
> audio is
> currently playing will also be interesting as these new technologies
> simply
> attempt to mix audio together rather than block when you're device is in
> use.

"your" - wtf voice input, can't you read the context?

You might be able to kludge up some sort of grep against a console based
> volume
> bar indicator.

I found an example: https://pypi.org/project/soundmeter/

This sounds like a fun little project to attempt using a bunch of Unix
> command
> line tools :)

Also to the rest of you, Happy New year.  It seems the list is working, the
previous post
was from October but clearly nothing was wrong!

  - Damion (this time from a laptop)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.lug.org.uk/pipermail/gllug/attachments/20230107/083bf951/attachment.htm>

More information about the GLLUG mailing list