KIO

kiod_agent.mm
1/* This file is part of the KDE libraries
2 SPDX-FileCopyrightText: 2017 René J.V. Bertin
3
4 SPDX-License-Identifier: LGPL-2.0-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5*/
6
7#import <CoreFoundation/CoreFoundation.h>
8#import <AppKit/AppKit.h>
9
10// Set the LaunchServices LSUIElement property programmatically in unbundled
11// ("nongui") executables, instead of in the app bundle's Info.plist file.
12// This function has to be called as early as possible in main(), and before
13// creating the QApplication instance.
14void makeAgentApplication()
15{
16 CFBundleRef mainBundle = CFBundleGetMainBundle();
17 if (mainBundle) {
18 // get the application's Info Dictionary. For app bundles this would live in the bundle's Info.plist,
19 // for regular executables it is obtained in another way.
20 CFMutableDictionaryRef infoDict = (CFMutableDictionaryRef) CFBundleGetInfoDictionary(mainBundle);
21 if (infoDict) {
22 // Add or set the "LSUIElement" key with/to value "1". This can simply be a CFString.
23 CFDictionarySetValue(infoDict, CFSTR("LSUIElement"), CFSTR("1"));
24 // That's it. We're now considered as an "agent" by the window server, and thus will have
25 // neither menubar nor presence in the Dock or App Switcher.
26 }
27 }
28}
29
30void setAgentActivationPolicy()
31{
32 [NSApp setActivationPolicy:NSApplicationActivationPolicyAccessory];
33}
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 8 2024 11:56:19 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.