MacOS – Programmatically ‘auto hide menubar’ in El capitan

macosmenu barplist

I really love the 'auto hide menubar' option in El Capitan, but sometimes I like it (private) sometimes I don't (work). Is there a way to show/hide it programmatically by changed it's value in a plist file? If so, in which plist file is that setting found? Any help is appreciated.

Update

A bit more details about the circumstances: I use applescripts or bash scripts a lot to automate certain mundane tasks, like opening all my professional applications when I arrive at work. Usually I even export an applescript as an application so I can run it with spotlight, thus by entering one simple command in spotlight, all the relevant apps open. I'd love to do be able to toggle the auto-hide feature like this. It doesn't matter that much to me if this is done via editing a plist file with bash commands or automating it in some way via applescript.

Best Answer

Here's how you can set the menubar to be hidden and unhidden using defaults:

To hide:

defaults write NSGlobalDomain _HIHideMenuBar -bool true

To show:

defaults write NSGlobalDomain _HIHideMenuBar -bool false

Once run, logout and log back in. Alternatively, you can run the following command as the logged-in user to restart Finder and show the changes:

killall Finder