2

So recently I came across the old Ubuntu login sound, and I decided I wanted to add it. So I added it, and it plays normally, but I have an issue. Normally, I have my headphones plugged in through the audio jack in the front of my PC, and as 99.99% of people know, when you insert something (like earbuds or headphones) in that jack, it overrides the main one in the back, where a regular speaker system might be connected (for desktop users). How can I play this file, on the command line, through that sound device/jack?

0

There are various ways this can be implemented.

If the front audio jack is wired in the AC-97 standard, and the motherboard only supports that standard, it includes a mechanical switch that interrupts the audio path to the rear jack, so it cannot be overridden without hardware modifications.

Newer motherboards use the HD-Audio wiring standard instead, which uses the mechanical switch in the front audio jack only to indicate to the system whether or not anything is plugged in, and the actual sound signal routing is controllable by software. In many modern sound chips, the ALSA sound drivers will present an "Auto-Mute Mode" control, which can be used to configure whether or not the rear jack output is muted when headphones are plugged in at the front.

If you have PulseAudio installed, most mixer tools will only show you the simplified mixer of PulseAudio by default. In this case, you'll want to access the underlying hardware mixer controlled by ALSA. With the alsamixer and amixer commands, you can do this by adding the option -cN, where N is a number starting from 0, identifying your sound card. You could first use the interactive alsamixer to find the right settings to adjust, then write a script that first uses command-line-based amixer to turn auto-mute off, then aplay or any command-line audio player to play the sound, and optionally amixer again to reset the auto-mute mode to whatever state you want it to generally have.

But if you want to play the login sound only through the rear jack while playing something different from the headphones, this would require a sound chip that treats the rear jack as a stereo output channel that is entirely separate from the front headphone output, instead of just an alternate output route for the main "left + right" output channel. In my experience, most sound chips tend to use the latter design, so playing one sound out of headphones while playing a different sound of the rear output may not be possible.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.