Hiding a macOS app from the Dock

From Free Pascal wiki
Jump to navigationJump to search

English (en)

Overview

While there is no way to hide an application from the Dock at runtime, this can be done at design-time if the application declares itself to be an agent or a background application. These two application categories and their attributes are explained below.

Agent applications

Agent applications do not appear in the Dock or in the Force Quit window; but they are visible to utilities like Activity Monitor, Unix command-line tools (eg top), as well as macOS API functions.. If the agent key exists and is set to YES in the application's .plist file, Launch Services runs the application as an agent. Although they typically run as background applications, they can come to the foreground to present a user interface if desired. A click on a window belonging to an agent application brings that application forward to handle events.

Agents are often shown in the macOS menu bar, in which case the agent application should provide a StatusBar (TTrayIcon) user interface and hotkeys if it needs a menu-like user interface.

For example, startlazarus is an agent application, launched by the Lazarus IDE when rebuilt. Similarly, the Dock and Login Window are also two applications that run as agents.

To declare an application to be an agent application, use Xcode to open the application's bundle Info.plist file:

  • add a property UIElement (or "Application is agent");
  • set the UIElement property's value to True;
  • save the Info.plist file.

infoplist agent.png

Background only applications

A background only application runs only in the background. If background application key exists and is set to YES, Launch Services runs the application in the background only. You can use this key to create faceless background applications. You should also use this key if your application uses higher-level frameworks that connect to the window server, but are not intended to be visible to users.

As background applications are never shown in the macOS menu bar, you should be launch/terminate the application with another GUI application.

To declare an application to be a background application, use Xcode to open the application's bundle Info.plist file:

  • add a property LSBackgroundOnly (or "Application is background only");
  • set the LSBackgroundOnly property's value to True;
  • save the Info.plist file.

infoplist bkgrndapp.png

See also

External links