Skip to content

Instantly share code, notes, and snippets.

@davidsharp
Last active December 16, 2019 15:12
Embed
What would you like to do?
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