Created
February 7, 2020 17:17
-
-
Save cdbattags/3872c9a404ed7aec6948b9ca7fb5cd37 to your computer and use it in GitHub Desktop.
Applescript for setting proper sound output device
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set codec to "CODEC" | |
set headphones to "headphones" | |
tell application "System Preferences" to quit | |
tell application "System Preferences" | |
activate | |
set current pane to pane "com.apple.preference.sound" | |
reveal anchor "Output" of pane id "com.apple.preference.sound" | |
end tell | |
tell application "System Events" | |
tell application process "System Preferences" | |
repeat until exists tab group 1 of window "Sound" | |
end repeat | |
set theRows to every row of table 1 of scroll area 1 of tab group 1 of window "sound" | |
repeat with aRow in theRows | |
set stringRow to (value of text field 1 of aRow as text) | |
if stringRow contains codec or stringRow contains headphones then | |
set selected of aRow to true | |
exit repeat | |
end if | |
end repeat | |
end tell | |
end tell | |
tell application "System Preferences" to quit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment