How to Programmatically Change "Automatically Hide and Show the Menu Bar" Setting?

I have encountered an issue with programmatically changing the "Automatically hide and show the menu bar" setting on my Mac. Ideally, I would like to toggle this setting using a shortcut. I found the relevant settings in defaults, but modifying them does not seem to change the menu bar behavior. Here's what I found and how I'm trying to change this setting:


  • Always
    • AppleMenuBarVisibleInFullscreen = 0
    • _HIHideMenuBar = 1
  • On Desktop Only
    • AppleMenuBarVisibleInFullscreen = 1
    • _HIHideMenuBar = 1
  • In Full Screen Only
    • AppleMenuBarVisibleInFullscreen = 0
    • _HIHideMenuBar = 0
  • Never
    • AppleMenuBarVisibleInFullscreen = 1
    • _HIHideMenuBar = 0


Set Always

defaults write 'Apple Global Domain' AppleMenuBarVisibleInFullscreen -bool false && defaults write 'Apple Global Domain' _HIHideMenuBar -bool true

Set Never

defaults write 'Apple Global Domain' AppleMenuBarVisibleInFullscreen -bool true && defaults write 'Apple Global Domain' _HIHideMenuBar -bool false


Additionally, I tried using killall SystemUIServer to restart the UI server, but this did not help either. Despite these commands, the menu bar behavior does not change. Has anyone successfully managed to change this setting programmatically? Any insights or suggestions would be greatly appreciated.

MacBook Pro 16″, macOS 14.4

Posted on Jun 5, 2024 7:57 AM

Reply
3 replies

Jun 5, 2024 12:45 PM in response to VikingOSX

I found these parameters myself using a simple method. First, I recorded all the settings into a file:

defaults read > defaults.never

Then I went into the settings, selected the "Always" option, and recorded the settings again into another file:

defaults read > defaults.always

After that, I compared the changes using git:

git diff --no-index ./defaults.never ./defaults.always

After running

defaults write 'Apple Global Domain' AppleMenuBarVisibleInFullscreen -bool false && defaults write 'Apple Global Domain' _HIHideMenuBar -bool true

the value in System Settings changes if I close and reopen the window, but the Menu Bar does not respond to the changes even after

killall SystemUIServer

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

How to Programmatically Change "Automatically Hide and Show the Menu Bar" Setting?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.