Is there anyway to hide menubar items in MacOS? - macos

I know I can "auto hide menu bar" in system preferences, however, what I like to do is hide items like this repository.
https://github.com/dwarvesf/hidden
This repository can hide items on right, but I wonder if I can hide left items (which are application menus).
Any idea is appreciated.

As for application menus on the left, those can't be hidden, I'm pretty sure.
Applications often have the option to enable or disable their menu bar helper app in the main preferences. If that doesn't help, e.g. if it's a full-fledged menu bar app, not just a helper, then to my knowledge the only solutions are Hidden Bar, which you mentioned, and Bartender.
I'm using the latter, and it does a very fine job. You have four options in Bartender's preferences:
Show (default macOS behavior)
Hide (menulet will be hidden in a special Bartender secondary menu bar, accessible via the triple-bullet icon ··· on the far right)
Always show (menulet will be visible in the main macOS menu bar as well as the secondary Bartender menu bar at the same screen position)
Always hide (menulet will be completely hidden)
Some older menulets seem to switch their position occasionally, e.g. after wake-from-sleep, and Bartender isn't yet able to fix the position of BitBar instances. But for the vast majority of menu bar apps and helpers it will work just fine.

Related

Adding a menu-bar to the app's window

I've been asked to add a menu bar to our ARC app's chrome window. So, two questions:
Is this possible?
If so, how would one define and interact with it?
To clarify, this would be similar to the drop-down menu that the usual Chrome window has in the top-right corner but it would contain custom entries.
No there's no way to add a menu button in the top bar. The functionality you're describing sounds similar to an action bar, which is the preferred way in Android to add a menu in the app (as an overflow list), since navigation bar menu keys are being phased out: http://android-developers.blogspot.com/2012/01/say-goodbye-to-menu-button.html

How can I get to the menu bar in my app in interface builder

XCode works in mysterious ways (at least to me).
I simply want to create a Preference pane in my app. When I run my app, the stock menu bar comes up (Apple, MyApp, File, Edit...) and the "Preferences" menu item is grayed out. It makes sense since I haven't started playing with it.
How on earth do I add/remove/activate/inactivate menu items? I'm not talking about adding anything new, simply using what should be there.
Thanks in advance.
NSMenu has "Auto Enable Items" enabled by default. That means if the menu item does not have it's action message hooked up, it will appear grayed out. So in your case, you would simply set the Preferences menu item's "Sent Action" to whatever action shows your preferences window. This can be hooked to some sort of showPreferencesWindow: method of your AppDelegate, or directly to the showWindow: method of a window controller.
To dynamically enable/disable menu items the best way is to implement the NSUserInterfaceItemValidation protocol which is excellently documented here
Edit: Your app's menu bar items live in the MainMenu.xib file. The menu bar appears as a "Main Menu" object on the left hand side (if you're using Xcode 4) Simply click on the items to modify them, and you can Ctrl+drag connections to and from them like any UI object.

How to get Icons at the top of my Mac Screen

On the very top of my Mac, there is a bar which has my battery percentage, the date and time, the volume, etc. There is also a dropbox folder. How can I create something that gets thrown up there? I'd like to put a few shortcuts in that menu bar. Is there a way to do it?
That bar is the equivalent to the system notification bar on Windows. You want to place your shortcuts on the dock (normally located at the bottom of your screen). You do this by drag and dropping.
While OS X provides no centralized tool to enable or configure menu extras, some of them can be rearranged and dragged off the menubar while depressing the ⌘ key. Also, all Apple-supplied menu extras can be found in the folder /System/Library/CoreServices/Menu Extras.
From Wikipedia
However, if you are determined to put your shortcuts on the bar, here is how to create menu extras
Alternatively, there are some free apps already created for this purpose. HimmelBar - Free, XMenu - Free, and MoofMenu - $5
You want to use the NSStatusBarItem class (see also the NSStatusBar class which represents the menu bar itself.)
Note that icons/menus created with this API do not "mix and match" with the OS-provided ones, but rather are aligned to the left of them and cannot be dragged by the user. Still, it's good enough for most uses.

how do you display an NSMenu programmatically?

I wrote a little app that lives in the NSStatusBar. I want to have a global shortcut that when hit, the menu bar's content is displayed, exactly like the behavior of spotlight.
I have added a global key shortcut to my application, but I am unable to get the meun bar to display. How can I do this? I tried with "popUpContextMenu" , but that method displays the menu in the bottom left hand corner, I want the menu to open up right under the NSStatusBar menu icon.
You can do it, apple provides a method for it popUpStatusItemMenu:
I don't think there is a supported way to do this without perhaps using the Accessibility framework to simulate a click on your status item. Regardless, it's probably not a good idea to abuse a menu in this way.
The Spotlight menu bar item does not use an NSMenu, it uses a custom window/view. You might consider going this route if you have some sort of custom view to display.

Applescript access to last.fm app via application icon in menu bar

I want to create an Applescript to drive the last.fm player app. I'm trying to do this via last.fm application icon in the menu bar rather than using the main application menus, as this approach (I think) won't cause last.fm to switch to the foreground. The overall plan is to bind my script to a quicksilver trigger so I can stop|start|skip|love|ban|tag tracks from the keyboard.
My problem is I can't find what UI element to bind the applescript to. I've used UI Browser to scan through the UI object model but it draws a blank with the last.fm icon in the menu bar. Any thoughts appreciated.
Items in the menu bar are NSStatusItem and the part of the menu bar in which they live is an NSStatusBar. I suspect from past experience, though I am not sure, that if your applescript would have caused the main application to switch to the foreground, it will cause the menu bar item to switch to the foreground to the extent that it can, meaning that the application in the foreground will probably lose focus.

Resources