How to set default audio device for switching to user?

How can I set a preference, or write a script or a command line or something, so that whenever the Mac switches to a specific user, it chooses a certain output audio device? This one user always needs the output to go to the headphones instead of the speakers, and I want to save the trouble of having to manually switching output devices every time that user logs in (from whatever the last user had set). How to set a specific audio device on user switch/login?

Mac Pro, OS X 10.10

Posted on Mar 26, 2020 3:35 AM

Reply

Similar questions

3 replies

Mar 26, 2020 11:22 PM in response to Michael Levin

Unfortunately, or fortunately, depending on your point of view, the answer is never that easy.


I should start by asking for clarification on when you want to switch in/outputs. You mention when 'the Mac switches to a specific user'... does that mean at login? or does that include multi-user switching where you may have multiple accounts logged in at once.


The latter is tricky, but the former might be achieved via a login script.


I couldn't find a simple, direct way to switch inputs (which did surprise me a bit), but you can always revert to UI Scripting (hence the 'unfortunate' part of my opening sentence :) )


This script will emulate user actions to choose a specific output device for audio, provided the Sound menu extra is enabled in System Preferences:


use AppleScript version "2.4" -- Yosemite (10.10) or later

use scripting additions


tell application "System Events" to tell process "SystemUIServer"

tell (menu bar item 6 of menu bar 1) --> check your menu bar item ID

click

click menu item "Internal Speakers" of menu 1 --> set the name of the output device to use

end tell

end tell


Like most UI scripts, it's crude and hacky - you may need to change the menu bar item ID to match your setup, but I couldn't find a consistent name to reference it by.


Once you get it working you should be able to save it as a login item so it runs when you log in.


Hacky, but the best I could come up with in a pinch. :)

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

How to set default audio device for switching to user?

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