Hi all,
I run a virtual windows machine using UTM on my M1 Mac Mini. Often like a few times a week, my audio just stops. Not only to the VM but to everything on my mac as a whole.
I think the solution is to kill core audio and restart it. I don't want to restart my mac, because that would kill what I'm working on in my VM and I've had to do this more times than I can count.
I need a terminal script that I can save as a .command file that will do the following:
sudo killall coreaudiod
Then, it needs to wait a second or 2 and enter my admin password. I don't know how to actually make these 2 things happen after the initial command.
If anyone could enlighten me on this, if it's even possible, that would be great.
Thanks in advance!
By John Lipsey, 6 June, 2024
Forum
macOS and Mac Apps
Comments
your script could do the following:
There is no way to directly have the script type your password into a terminal, because the interpreter would try to interpret your password as a command.
Before you could run the script, you would need to run:
chmod +rwx /path/to/script.command
If you don't, you will get an error saying you don't have permition to execute.
I would recommend the following script which will restart coreaudiod and play an alert sound to test for audio.
Copy and paste the following script into text edit and save it with the ".command" extension.
Sometimes text edit will convert your document, so make sure you are using plane text by pressing command+shift+T untill you here "Make Plain Text".
Hope this helps.
/bin/bash
#When ran, enter your admin password. Sudo will be waiting for your password when ran.
#kill the CoreAudioD Process
sudo killall coreaudiod
#coreaudiod should (hopefully) restart on it's own, but don't know.
#add a pause for coreaudio to restart
sleep 2
#This can be changed if need be.
#play the default alert sound to check for audio
printf \\a
You may need to restart VoiceOver for it to work.
I ran the command on my system and I needed to restart voiceover in order for it to be heard.
Thanks a lot!
This does exactly what I need, and I've pinned it to my doc for easy access in case all of my audio goes away. Thanks for the help!
I didn't need to restart voiceover, but voiceover took an extra 15 to 20 seconds after the rest of my audio came back to actually start talking again.
Cheers!
Even better than adding it to the dock:
You could open system settings, select keyboard, select keyboard shortcuts, and somehow assign a shortcut to open that script. You might have to go into the Shortcuts app on the Mac and create a shortcut which opens the file, then assign it a keyboard command.