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.
As answered by Rich Trouton on apple.stackexchange.com
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
MacOs Sierra
As trevordmiller points out in the comment below, in Sierra it seems you have to close your terminal first to make the change have any effect.
killall Finder
alone isn't enough –
Tympany As of 10.12.5 I am finding that @trevordmiller is only partially correct; Every application seems to need to be individually restarted to register the new setting. In other words, If I use:
defaults write NSGlobalDomain _HIHideMenuBar -bool false
killall Finder
this only shows the menu bar while Finder is active. To show it in other apps, I have to restart them. Killall Finder
is not required in any way other than that it restarts Finder app and registers the setting for it. Same for restarting any terminal app.
From AppKit release notes:
NSApplication (New since WWDC Seed)
10.11 supports a new type of menubar behavior that hides the menubar during normal non-fullscreen interaction. The menubar shows itself automatically when the mouse moves into a hot area at the top of each display. When this mode is enabled, the NSApplication.presentationOptions property will include the NSApplicationPresentationAutoHideMenuBar value.
Prior to 10.11, the SetSystemUIMode API provided by HIToolbox, and the setPresentationOptions API of NSApplication provided by AppKit, did not allow explicitly enabling an auto-hiding menubar without also hiding the Dock. -setPresentationOptions now allows the options to contain AutoHideMenuBar without also including HideDock or AutoHideDock. To ensure compatibility with existing applications, the SetSystemUIMode API will only allow applications linked on 10.11 and later to pass the combination of kUIModeNormal and kUIOptionAutoShowMenuBar; if this combination is specified by an application linked on Yosemite or earlier, the AutoShowMenuBar option is ignored
You are looking for this bit. Flip it as you need.
typedef NS_OPTIONS(NSUInteger, NSApplicationPresentationOptions) {
/* Flags that comprise an application's presentationOptions */
NSApplicationPresentationAutoHideMenuBar = (1 << 2),
} NS_ENUM_AVAILABLE_MAC(10_6);
Too late. If it helps someone else, a shortcut could make it handy.
Open Automator -> Select Service -> Service receives selected text -> Select no input in any application -> Add Run Shell Script action -> Add the following lines.
bool=$(defaults read NSGlobalDomain _HIHideMenuBar)
if [ "$bool" == 0 ]; then
defaults write NSGlobalDomain _HIHideMenuBar -bool true
else
defaults write NSGlobalDomain _HIHideMenuBar -bool false
fi
Save it. (These steps creates a service that runs whenever the system boots.)
To give a shortcut,
Go to System Preferences -> KeyBoard -> Shortcuts -> Services -> Scroll to last to find General section -> Set a preferred shortcut for the service.
❯ /usr/bin/defaults write NSGlobalDomain _HIHideMenuBar -bool [true|false]
But you'll have to close instances of the Finder application, and fire it up again:
# `-g` don't bring app to foreground, `-a` specify app name
❯ killall Finder && open -ga /System/Library/CoreServices/Finder.app/
As a hotkey triggered script to toggle it on/off (hide/unhide):
if (( `/usr/bin/defaults read NSGlobalDomain _HIHideMenuBar` == 0 ));
then
/usr/bin/defaults write NSGlobalDomain _HIHideMenuBar -bool true \
&& killall Finder \
&& open -ga /System/Library/CoreServices/Finder.app/
else
/usr/bin/defaults write NSGlobalDomain _HIHideMenuBar -bool false \
&& killall Finder \
&& open -ga /System/Library/CoreServices/Finder.app/
fi
- can be used with Alfred workflows, Hammerspoon, Keyboard maestro, Automator, etc.
© 2022 - 2024 — McMap. All rights reserved.