Skip to content

Instantly share code, notes, and snippets.

@davidsharp
Last active December 16, 2019 15:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidsharp/209485fbb7c4d6cbbb362c6139e38f66 to your computer and use it in GitHub Desktop.
Save davidsharp/209485fbb7c4d6cbbb362c6139e38f66 to your computer and use it in GitHub Desktop.
bitbar plugin for toggling between mono and stereo audio
#!/bin/bash
if [[ "$1" = "toggle" ]]; then
osascript -l JavaScript<<'END'
const appSE = Application("System Events");
const appPrefs = Application("System Preferences");
appPrefs.activate();
appPrefs.panes.byId("com.apple.preference.universalaccess")
.anchors.byName("Hearing").reveal();
const box = appSE.applicationProcesses.byName("System Preferences")
.windows.byName("Accessibility")
.groups.at(0)
.checkboxes.byName("Play stereo audio as mono");
appSE.click(box);
appPrefs.preferencesWindow.close();
END
fi
function runbitbar(){
echo "⌁|bash=$0 param1=toggle terminal=false"
}
runbitbar
@davidsharp
Copy link
Author

New version uses JXA (Javascript for automation) over AppleScript, and has a bit more specificity, rather than assuming the locations of window elements

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment