Skip to content

Instantly share code, notes, and snippets.

@jldeen
Created October 15, 2020 19:37
Show Gist options
  • Save jldeen/5f070004d1f02825900aa0bb7aa5e6e6 to your computer and use it in GitHub Desktop.
Save jldeen/5f070004d1f02825900aa0bb7aa5e6e6 to your computer and use it in GitHub Desktop.
function toggleMenu () {
~/.dotfiles/bin/toggleMenuBigSur.sh
}
#!/usr/bin/env osascript
try
if application "System Preferences" is running then do shell script "killall 'System Preferences'"
end try
repeat until application "System Preferences" is not running
delay 0.1
end repeat
tell application "System Preferences"
reveal anchor "Main" of pane id "com.apple.preference.dock"
end tell
tell application "System Events" to tell application process "System Preferences"
repeat while not (exists of UI element "Automatically hide and show the menu bar" of window "Dock & Menu Bar")
delay 0.1
end repeat
click UI element "Automatically hide and show the menu bar" of window "Dock & Menu Bar"
repeat while not (exists of UI element "Automatically hide and show the menu bar" of window "Dock & Menu Bar")
delay 0.1
end repeat
end tell
try
if application "System Preferences" is running then do shell script "killall 'System Preferences'"
end try
@gabrielbacha
Copy link

Ah perfect. Just what I was looking for. Exactly the same issue for me. Used to work in Catalina (under General), and now I get the same error "Can't Get Anchor "Main" of pane id "com.apple.preference.dock".

I'll keep an eye here to see when it gets resolved!

Thanks for this

@gabrielbacha
Copy link

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