aboutsummaryrefslogtreecommitdiffstats
path: root/Sources/WireGuardApp/UI/macOS/LoginItemHelper/main.m
blob: 8d074d9505dc3b4591027cb33d34cd09f057d969 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.

#import <Cocoa/Cocoa.h>

int main(int argc, char *argv[])
{
    NSString *appIdInfoDictionaryKey = @"com.wireguard.macos.app_id";
    NSString *appId = [NSBundle.mainBundle objectForInfoDictionaryKey:appIdInfoDictionaryKey];

    NSString *launchCode = @"LaunchedByWireGuardLoginItemHelper";
    NSAppleEventDescriptor *paramDescriptor = [NSAppleEventDescriptor descriptorWithString:launchCode];

    [NSWorkspace.sharedWorkspace launchAppWithBundleIdentifier:appId options:NSWorkspaceLaunchWithoutActivation
                                additionalEventParamDescriptor:paramDescriptor launchIdentifier:NULL];
    return 0;
}