Manipulate (hide) third-party menu bar icons on macOS 10.10+

I would like to programmatically manipulate the menu bar icons on macOS, ideally supporting Yosemite, El Capitan and Sierra in Swift. What I'm mostly looking for temporarily hides some or all third-party icons (when you have a dozen of them, they seem crazy there).

An example implementation is Bartender ( https://www.macbartender.com ). I would like to create a simpler version where the menu bar icon app will toggle all other third-party icons except itself when it is clicked. I do not need to display icons anywhere else.

Looking at Bartender, it seems that there is a need for a helper application with administrator rights. What else, if I debug one of my applications that creates a menu item, I see the following in the console while Bartender is running:

2016-12-06 10:14:47.936 MyApp[2747:22676] Bartender: Loaded BartenderHelperTwoOneThree 

So it looks like Bartender is introducing his assistant into the process, right? I just checked and the Helper is the BartenderHelper.osax file inside /Library/ScriptingAdditions . This package contains a binary file with the same name, as well as a PlugIns folder containing BartenderHelperTwoOneThree.bundle that contains a binary file with the same name.

I have no idea where to look, and my searches on SO and Google have so far given me nothing. I have no sandbox restrictions.

Thanks.

+7
cocoa swift swift2 macos
source share

No one has answered this question yet.

See related questions:

nineteen
How to make a menu bar application (system tray) for OSX in Python?
8
resignFirstResponder () in third-party keyboards
4
macOS: how to show the main menu of a menu bar without a dock icon
3
Pros and cons of splitting Cocoa utility application in binary binary + main app binary?
2
How do I configure the Swift helper application to not include the same structures as the main application?
one
Can I execute the binary located inside the container for the macOS application sandbox?
one
Menu bar not showing in Android Studio
one
How can I get the list of icons currently on the Mac menu bar?
0
How to add Finder / Services menu items to your own MacOS context menu
-2
How to programmatically determine the installation path of a third-party application on a Mac?

All Articles