Skip to content

Instantly share code, notes, and snippets.

@chris-sev
Forked from jldeen/function.sh
Created May 25, 2021 15:35
Show Gist options
  • Save chris-sev/15f9947d7c980ba785a2813feb36e51a to your computer and use it in GitHub Desktop.
Save chris-sev/15f9947d7c980ba785a2813feb36e51a to your computer and use it in GitHub Desktop.

Revisions

  1. chris-sev revised this gist May 25, 2021. No changes.
  2. @jldeen jldeen created this gist Oct 15, 2020.
    3 changes: 3 additions & 0 deletions function.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    function toggleMenu () {
    ~/.dotfiles/bin/toggleMenuBigSur.sh
    }
    25 changes: 25 additions & 0 deletions toggleMenuBigSur.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    #!/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