Script to prevent speakers going to sleep

I'm sure a lot of people can relate to this, I have a Bose speaker plugged in to my iMac via the headphone socket. Like a lot of modern day speakers these have an inbuilt power saving feature which means it goes to sleep after a few minutes. I have seen online like here...
and here...

it is possible to do this on a Mac and then use KM to run the audio repeatedly to prevent the power saver cutting in?

Or maybe there is an easier solution using KM?

Yes, KM has a Play Sound action:


In the popup menu you can select any sound file with “Other”:


Set the macro trigger to a Periodic Trigger and play some “silent” sound with that.

1 Like

That's great, thanks Tom.
I set a sound and then set the volume to 0% so it's silent. This does do what I achieve although my concern now is that as I have it set to repeat constantly to every two seconds it will prevent the computer from gong to sleep at all.

Is there a way to make the macro run only when the computer is awake and for the macro to go to sleep when the computer goes to sleep?

Why every 2 seconds if the speakers go to sleep after a few minutes? If the speaker goes to auto-sleep after for example 3 minutes, I would play the sound every 2 minutes 50 seconds or so.

Concerning the computer sleep (on my iMac 2019, 10.15.3):

When I put the Mac to sleep manually then the Play Sound macro will stop triggering (= Computer will not wake up).
However, the macro does prevent my Mac from going to sleep automatically.

Here is a 5-seconds silence file: (97.0 KB)

Try if it works; then you don’t have to change the volume.

1 Like