Cocoa Application with Menubar menu but no Dock icon / switch

This is another of them: "How to switch from work using the dock icon to work without one" with a question. I don't want the dock icon, but I need a menu bar when the application is in front. Is it possible?

Launching an application with LSUIElement set to 1 in plist will launch the application without a dock icon, will not appear in the list of command switches and without a menu .

You can switch from this mode to “normal” mode, all three of which are enabled through SetSystemModeUI from 10.2 and then through NSApplication setApplicationActivationPolicy from 10.6, but, nevertheless, there is no return to the previous mode (figure).

Thus, one way: run LSUIElement = 1, and then activate the menu bar when the application receives focus and deactivates it in the application that loses focus. Alas, I can’t find a way to do this.

Does anyone help?

Yours faithfully,

Franc

+3
source share
2 answers

Unfortunately this is not possible. You can convert a process type in only one direction (from a background application to a foreground application), and not vice versa.

+1
source

I was also looking for a solution, but it turned out to be quite simple: In the Info.plist project file, you need to add

"Application is an agent (UIElement)" = YES

+1
source

Source: https://habr.com/ru/post/1742107/


All Articles