Set headphones as default audio output

rtolosa
New Contributor II

Hi all,
We are working on a way to disable the internal speakers of any device and make sure that they can only use headphones to listen to any audio coming out of the computer.
We are using Soundflower as a work around and it's working like a charm, but we are trying to find the .plist or terminal command that can set the default output device order for the system, so we can make sure that when a user plugs the headphones, they are activated by default, as soon as they unplug it, sound flower is selected as second option, and audio is deactivated.
We know there's a plist because if we change it manually it keeps the configuration, but we are unable to find it to manage it via CASPER.
Any clue or recommendation?
Thank you guys!!

4 REPLIES 4

mm2270
Legendary Contributor III

I'm not sure how easy it would be to manage that via Casper or a Configuration Profile, but have you tried using Composer in either a snapshot, or preferably the monitor system changes option, to see if you can figure out which plist is being modified? Composer can be very good for determining what gets touched when changes are made if you do it the right way.

rtolosa
New Contributor II

We'll give it a try and come back with the results. Thank you mm2270! :D

Nix4Life
Valued Contributor

@rtolosa I just did something like this a few months back for our conference room, but I used a script and a LaunchDaemon. As @mm2270 mentioned not to sure about Jamf handling it. I adapted it for my home use and Bluetooth speakers. It will default to internal, but once Bluetooth speakers are turned on , it switches to them. It requires audioswitcher. I used the following script, set with a LaunchDaemon for 60 secs

#!/bin/bash
AUDIOSWITCHER='/usr/local/bin/AudioSwitcher'
CURRENTAUDIO=`/usr/local/bin/AudioSwitcher  -c `
AUDIOCHECKBOOM=`/usr/local/bin/AudioSwitcher  -a  | egrep -c "UE MINI BOOM" `
AUDIOCHECKFLOWER=`/usr/local/bin/AudioSwitcher -a  | egrep -c "Built-in Output" `
if [ "$CURRENTAUDIO"  == "UE MINI BOOM"  ]; then
   echo " Unit using default audio....."
      exit 0
  else
     if [ "$AUDIOCHECKBOOM"  -ge   "2"  ];then
         $AUDIOSWITCHER -t input  -s "UE MINI BOOM";$AUDIOSWITCHER  -s "UE MINI BOOM"
   else
      if [ "$AUDIOCHECKBOOM"  -lt   "2"  ];then
         $AUDIOSWITCHER  -s "UE MINI BOOM"
   else
      if [ "$AUDIOCHECKBOOM"  ==   "0"  ] && [ "$AUDIOCHECKFLOWER"  -ge   "2" ];then
         $AUDIOSWITCHER -t input  -s "Built-in Input";$AUDIOSWITCHER -s "Built-in Output"
   else
      if [ "$AUDIOCHECKBOOM"  ==   "0"  ] && [ "$AUDIOCHECKFLOWER"  -lt   "2" ];then
         $AUDIOSWITCHER -s "Built-in Output"

      exit 0 
      fi
   fi
 fi
 fi
fi

Just another option

Larry

rtolosa
New Contributor II

Hi both,
I first tried with COMPOSER, and I found the file after the snapshot, but even deploying those changes, it's not working. Everytime you plug or unplug the jack, the file is overwritten, it seems that there's a template file somewhere, where the changes need to be done, but I can't manage to find it. I'm pretty sure that this template needs to be modified for the changes to be applied, but no luck until now.
About the script approach, I don't want to stress the computer with an ongoing script, when I'm sure this preference file exists. If you try to do it yourself, you'll see that if you plug a pair of headphones, and you change the output in audio preferences, the next time you plug them the system will recall your selection.
I'm still working to find this file, if anybody have any idea it will be really appreciated.
Thank you so much for your help @mm2270 and @LSinNY :D