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