I have a speaker (Bose SoundLink Mini) connected to my MacBook Pro, and it switches off after periods of non-use. This means that it will shut off even while I am at the computer, if a sound hasn't been played in awhile. What is the most sensible way to have a very quiet (ideally inaudible) sound played every fifteen minutes? I have a little familiarity with AppleScript and am happy to learn more; I don't yet know anything about other scripting methods.
2 Answers
Simply create a launch agent which repeatedly says something (or plays a sound) and load it:
Create a plist with nano in Terminal:
nano ~/Library/LaunchAgent/usr.home.bose.wakeup.plistCopy the following lines and paste it into the Terminal window:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Disabled</key> <false/> <key>Label</key> <string>usr.home.bose.wakeup</string> <key>ProgramArguments</key> <array> <string>/usr/bin/say</string> <string>wake</string> <string>up</string> <string>you</string> <string>lazy</string> <string>Bose</string> <string>SoundLink</string> <string>Mini</string> </array> <key>RunAtLoad</key> <true/> <key>StartInterval</key> <integer>887</integer> </dict> </plist>Save the file with ctrlO and exit nano with ctrlX
Load the plist with:
launchctl load ~/Library/LaunchAgent/usr.home.bose.wakeup.plist
You can use other voices by adding the option -v $VOICE. To get the list of all available voices enter say -v ? in Terminal.
Example:
...
<array>
<string>/usr/bin/say</string>
<string>-v</string>
<string>Agnes</string>
<string>wake</string>
...
The downside of say: you can't set a sound level!
Therefore an alternative launch agent with afplay instead (you can set the sound level with the -v option):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Disabled</key>
<false/>
<key>Label</key>
<string>usr.home.bose.wakeup</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/afplay</string>
<string>-v</string>
<string>0.05</string>
<string>/System/Library/Sounds/Submarine.aiff</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>StartInterval</key>
<integer>887</integer>
</dict>
</plist>
-
So the entire
saypart of your answer is not an answer to the question? Should it be two separate answers, or re-ordered so the useful answer is more prominent?user150109– user1501092020-04-13 11:47:04 +00:00Commented Apr 13, 2020 at 11:47 -
@theonlygusti The
saypart answers the question "What is the best way to occasionally play a sound?" but doesn't meet one contraint: to [be] very quiet (ideally inaudible). I rather wanted to show how to use a launch agent to repeatedly play a sound.klanomath– klanomath2020-04-13 11:59:04 +00:00Commented Apr 13, 2020 at 11:59 -
1Thank you! Yes, I'm sure I could record something more quiet, or perhaps even a recording of silence would work.Wallfacer– Wallfacer2020-04-14 11:13:28 +00:00Commented Apr 14, 2020 at 11:13
For this specific speaker, it turns out there is an easier answer: just press and hold the bluetooth and + buttons until it verifies that auto-off has been disabled. Still, thank you all for the input!
/usr/bin/afplaymight help. What's your level of expertise regarding shell scripts, AppleScript, launchd/cron?