How can I get the current sound output device name with AppleScript?

For example, in my System Preferences: Sound pane "Internal Speakers" is currently selected. All I need to do is retrieve that device name -- "Internal Speakers" or "Headphones" or "Bluetooth Speakers" -- whichever is currently in use.

(I do not need a switcher/changer to another device.)

3 Answers 3


SwitchAudioSource http://code.google.com/p/switchaudio-osx/ is a command-line utility which works under Lion and Mtn Lion (I don't know about newer OS X versions). If it works for you, then you can use it in an AppleScript, as follows:

on run

    set theSwitch to "path_to_SwitchAudioSource"
    set theLine to "Current audio output device is:"

    do shell script theSwitch & " -c"
    display dialog theLine & return & return & result buttons {"OK"}

end run
  • That's a nifty little util! And it works great, even under Yosemite. Thanks!
    – schmelding
    Dec 8, 2014 at 21:33
  • @Alepsis thanks for the SwitchAudioSource tip - really nice. I've used BetterTouchTool to add some touchbar buttons and widgets to show status and change state. I've put the code on GitHub.
    – gmorrell
    Jun 28, 2018 at 10:22

Just to help out a bit more:

In your main user directory /home// create a directory named 'bin' and put SwitchAudioSource in there.

Here's some AppleScript which switches back and forth between two sources, the default 'headphone' mini jack output on the back of my Mac Mini (a laptop should be different), and my Sennheiser USB headsest.

Call me 'Captain Obvious', but here you go:

`on run

set theSwitch to "~/bin/SwitchAudioSource"
set theSource to do shell script theSwitch & " -c"

if theSource = "Built-in Output" then
    do shell script theSwitch & " -s \"Sennheiser USB headset\""
    do shell script theSwitch & " -s \"Built-in Output\""
end if

end run`


Something like this.

tell application "System Preferences"
    reveal pane id "com.apple.preference.sound"
end tell

tell application "System Events"
    tell application process "System Preferences"
        tell tab group 1 of window "Sound"
            click radio button "Output"
            tell table 1 of scroll area 1
                set selected_row to (first UI element whose selected is true)
                set currentOutput to value of text field 1 of selected_row as text
                display dialog currentOutput
            end tell
        end tell
    end tell
end tell

if application "System Preferences" is running then
    tell application "System Preferences" to quit
end if
  • 2
    Thanks! Is there a way do it without having to launch System Preferences?
    – schmelding
    Aug 19, 2014 at 1:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .