Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Controlling sound output device with terminal

Does anyone know if there is a command for this? I know you can control various plist settings via terminal, but haven't found a way to change sound output device. I manage a lab, and I'd like to be able to send a command to all the computers via remote desktop to change to headphones. It's managed through user profiles, so I can't just set it once and forget about it.


I found that the "say" command has a flag -o, which stands for out, but I don't know if that means output or something else.


$ say -o

say: option requires an argument -- o

Usage: say [-v voice] [-o out] [-f in | message]

Mac OS X (10.6.8)

Posted on Dec 7, 2011 3:48 PM

Reply
4 replies

Jun 1, 2017 2:14 AM in response to X423424X

hey i hope you see this, can i use this terminal line : Examples: SwitchAudioSource -s 'Built-in Line Output' to solve the problem of the digital out locking or sporadically turning on and off in the headphone port. I have the same problem as many others that for years my 2011 MBP keeps switching the output in the headphone jack to optical out (greyed out icon, red light of death), I've literally tried all solutions offered online. I've reset Prams, Vrams. Deleted the Audio pref file (reinstalled too), poked the hole, cleaned the sensors and what not. I have no need for the optical out and was thinking i could just remove the entire function with terminal or at least disable the script that runs the command to activate or de-activate the entire optical function in the port. I have tried also running idefrag and all though I have some fragmented files it doesn't look like any Audio preference files are fragmented (I had seen 1 user with the same issue found the file was massively fragmented and fixed the issue by defraging, but I've lost the article.

Dec 7, 2011 5:17 PM in response to Dreyfuzz

I needed to do this when I attached my TV to my mac pro where I wanted to toggle between my mac pro's audio line out speakers and the TV's speakers via (optical) digital out. The intent was to automatically switch the speakers when I enabled/disabled the TV via SwitchResX. There were two possibilities. First, a compiled utility to do change output devices. Second, GUI applescripting the Audio output system preferences. I preferred a compiled command line utility to applescripting since it's faster and doesn't require having the Audio prefs popping up and closing.


I found two command line utilities to change output devices:


audiodevice


Examples: audiodevice output 'Line Out'

audiodevice output 'Digital Out'

SwitchAudioSource


Examples: SwitchAudioSource -s 'Built-in Line Output'

SwitchAudioSource -s 'Built-in Digital Output'

I chose audiodevice but there's nothing wrong with SwitchAudioSource.


I could supply the GUI applescripts here but will do so only if someone requests it since it would make this post too long.


------


Mumbling to myself...


Now if I just could find a command line utility to change the cursor size so I don't have to do that via GUI applescript.

Controlling sound output device with terminal

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.