summaryrefslogtreecommitdiff
path: root/sbdidlaunch.mm
blob: 91dbcfe3db2b72df7503f23a4dc5aa0cca042685 (plain)
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
#import <CoreFoundation/CoreFoundation.h>

extern "C" void *SBSSpringBoardServerPort();

void OnDidLaunch(
    CFNotificationCenterRef center,
    void *observer,
    CFStringRef name,
    const void *object,
    CFDictionaryRef info
) {
    CFRunLoopStop(CFRunLoopGetCurrent());
}

int main() {
    CFNotificationCenterAddObserver(
        CFNotificationCenterGetDarwinNotifyCenter(),
        NULL,
        &OnDidLaunch,
        CFSTR("SBSpringBoardDidLaunchNotification"),
        NULL,
        NULL
    );

    if (SBSSpringBoardServerPort() == NULL)
        CFRunLoopRun();

    return 0;
}