How to Send Sound to System Speakers when Headphones are Plugged In?

I'm trying get some kind of alert when my laptop is:

  • Running NoSleep so that closing the lid does not trigger Sleep,
  • Playing music through the headphones (with the lid closed)
  • Unexpectedly on battery power because the MagSafe connector has popped off.

I use the Power Status Changed trigger and the Battery function to trigger a warning message on the screen, and a Shell Script line from @Alexander https://forum.keyboardmaestro.com/t/how-to-tell-when-the-laptop-lid-is-closed/34274/3 to add a sound if the lid is closed. But if headphones are plugged in and I don't have them on my head, I still don't hear the warning.

Is is possible to direct a sound, system sound, music, whatever, to the System Speakers even when headphones are plugged in?

I think you're going to either have to use a third-party Terminal app, or do some GUI scripting—both options are covered here:

There's no way I'm aware of to direct a given sound output to a particular device without changing the output device (at least at the user level, as opposed to in Swift, Obj C, etc.)

-rob.

I just tested the switchaudio-osx, which can be installed with homebrew, and it works on my system perfectly.

brew install switchaudio-osx

So you could use it to get current audio-output device.
Change to built in speakers.
Play sound.
Change back to previously used audio-output.

And as it can list current output device, I can use it for a macro to display audio device in the menubar :slight_smile:

FOLLOW-UP: I found a native way to always show the audio output in the menubar.
You can set it in System Settings and Control Center. I had looked under Sound as an idiot.

I don't know, but for comparison, I do know that Blackberry phones made it physically impossible for even their OS to listen to any sound using the built-in microphone if anything, even a stub, was inserted into the microphone slot. The idea was to make the phone "untappable" by malicious software.

It is common practice (but not universal practice) for hardware to limit access to speakers when any device is plugged into the headphone jack. Decades ago I was visiting a Radio Shack which had an amp on display with headphones plugged in, and I put the headphones on my head and turned up the volume on the amp very high. Suddenly I saw the store clerk running towards me and turning down the sound. I hadn't realized that the sound was coming through both the headphones and the external speakers. This is the kind of thing that manufacturers have been trying to avoid. :loud_sound: :dizzy_face: :headphones:

Thanks Rob, Jimmy,

These are two good leads that should help a lot.

I've been aware of that, with simple devices like boomboxes, cassette players, etc., but I don't know what's true for my Mid-2012 Macbook Pro.

I'm now recalling that I have been able to use an add-on utility to send sound to multiple devices, both the headphone jack and a Bluetooth headset. Perhaps the same utility would work here, turning it on and off with KBM. But there still may be hardware limitations. Thanks for the memory prompt.

If the other suggestions don’t work out, SoundSource can route audio from any app to any output device. It doesn’t have AppleScript or CL support, but it does work with macOS Shortcuts quite nicely.

??

I found soundsource in a list of "New Casks' that I had saved from a previous Homebrew update, but Googling "CL" is not providing useful results.

IIRC, the tool I used before added entries to the Sound icon in the Mac Toolbar, so switching back and forth could be as simple, after it's set up, as having KBM pick the right menu items.

Thanks for an additional trail to pursue.

Command line :slightly_smiling_face:

1 Like

Doh! Should have been obvious but it wasn't.

1 Like

Back to the original problem —

It seems the external speakers are cut off when the lit is closed, even if I have NoSleep running so that the system doesn't sleep. It will continue to play music through my headphone with the lid closed, but not throught the internal speakers, so my attempt at an audible alert ends up doing nothing.

Any ideas of how to override the "lid closed = speaker cutoff" issue to keep the speakers working?.

I did some exploring on Ask Different (apple.stackexchange.com). It appears to be a limitation on MacBook Pro through 2018 that was changed in 2019. I don't yet have specific model details and 2019 iMacs appear to still have the problem. Someone pointed out that it has to be an OS thing and not a hardware limitation if the computer makes an audibile chime from the builtin speakers when rebooting while headphones are plugged in.

2019 appears to be a good year for MacBook Pro as that is also the year they fixed a keyboard butterfly switch problem that had been creating problems for years.

I gotta give you some credit @August. A 2012 Macbook? I had a 2013 Mac Pro (it did NOT look like a trashcan dammit. It was beautiful.) And at first, it took everything I could throw at it. Websites. Virtual machines. The occasional movie or crazy-ass shell script.

But by last year I was pleading with Apple to give me something new.

I even ordered a Mac mini. But canceled that when the Studio was announced.

It's time August. You should upgrade. You deserve it.

I agree that I "deserve" it. Unfortunately, right now I would need a GoFundMe campaign, a sponsor, or a short technical editing gig, all of which are essentially someone else thinking I deserve it.

1 Like

I just verified that my computer does indeed make an audible chime when rebooting, even with headphones plugged in to the headphone jack. That's what I remembered, and I just confirmed it at a restart.

So somewhere there may be an OS hook to force sound to go through the speakers. Maybe it's just that chime sound that is supported, I don't know. But it would be both cool and helpful, so I'm still researchinng it, slowly.