/
AppDelegate.m
48 lines (35 loc) · 1.19 KB
/
AppDelegate.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//
// AppDelegate.m
// cmd-eikana-helper
//
// Created by 岩田将成 on 2016/10/01.
// Copyright © 2016年 eikana. All rights reserved.
//
#import "AppDelegate.h"
@interface AppDelegate ()
@property (weak) IBOutlet NSWindow *window;
@end
@implementation AppDelegate
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
// Check whether the main application is running and active
BOOL running = NO;
BOOL active = NO;
NSArray *applications = [NSRunningApplication runningApplicationsWithBundleIdentifier: @"io.github.imasanari.cmd-eikana"];
if (applications.count > 0) {
NSRunningApplication *application = [applications firstObject];
running = YES;
active = [application isActive];
}
if (!running && !active) {
// Launch main application
NSURL *applicationURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@://", @"io.github.imasanari.cmd-eikana"]];
[[NSWorkspace sharedWorkspace] openURL:applicationURL];
}
// Quit
[NSApp terminate:nil];
}
- (void)applicationWillTerminate:(NSNotification *)aNotification {
// Insert code here to tear down your application
}
@end