As far as functionality, I'd just like to assign multiple keyboard shortcuts to individual audio outputs. For instance:
cmd F12 --> Airpods
cmd F11 --> Macbook speakers
cmd F10 --> Headphones
I'm very new to this and learning so I'm not looking for a specific answer on how to write it - I'm more interested in the concept and libraries to research to see how far I can get on my own. I wrote something with Python using pynput keyboard and mouse, but it's not exactly what I had in mind since it's taking control of the mouse and using coordinates on my display it's one layout change from not working. (Python preferred as that's what I'm learning, but open to all ideas and suggestions)
Thanks in advance!
CodePudding user response:
Install switchaudio-osx e.g. with
brew install switchaudio-osx
Use
SwitchAudioSource -a
to show me exactly how all my speakers are named.Create some 1-line AppleScripts, saving them as applications:
do shell script "/usr/local/bin/SwitchAudioSource -s 'MacBook Pro Speakers'"
- Use Apptivate to give the saved AppleScript app a keyboard shortcut.
Note : As mentioned in other answers, there are other popular alternatives to Apptivate for assigning a keyboard shortcut to an AppleScript application.
Using SwitchAudio has the advantage of not relying on UI list positions. A big help if your list changes. Run SwitchAudioSource
with no options to see help text.