This repository was archived by the owner on Dec 28, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.m
More file actions
executable file
·33 lines (31 loc) · 1.33 KB
/
main.m
File metadata and controls
executable file
·33 lines (31 loc) · 1.33 KB
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
//
// main.m
// HotKeys
//
// Created by Ankur Kothari on 21/03/08.
// Copyright Ankur Kothari 2008. All rights reserved.
//
#import <Cocoa/Cocoa.h>
#import <Carbon/Carbon.h>
int main(int argc, char *argv[]) {
{
NSAutoreleasePool *l = [[NSAutoreleasePool alloc] init];
NSUserDefaults *def = [NSUserDefaults standardUserDefaults];
[def registerDefaults:[NSDictionary dictionaryWithObject:[[NSBundle mainBundle] pathForResource:@"portable" ofType:@"hotkeys"]?:[@"~/.hotkeys" stringByExpandingTildeInPath] forKey:@"HotKeysFile"]];
ProcessSerialNumber p;
if(!GetCurrentProcess(&p)) {
NSDictionary *d = (NSDictionary*)ProcessInformationCopyDictionary(&p, kProcessDictionaryIncludeAllInformationMask);
long long t = [[d objectForKey:@"ParentPSN"] longLongValue];
[d release];
p.highLongOfPSN = (t >> 32); p.lowLongOfPSN = (t << 32) >> 32;
d = (NSDictionary*)ProcessInformationCopyDictionary(&p, kProcessDictionaryIncludeAllInformationMask);
if([[d objectForKey:@"CFBundleIdentifier"] isEqualToString:@"com.apple.loginwindow"]) {
[NSTask launchedTaskWithLaunchPath:[[NSBundle mainBundle] pathForResource:@"HotKeysAgent" ofType:nil] arguments:[NSArray arrayWithObject:[[NSUserDefaults standardUserDefaults] stringForKey:@"HotKeysFile"]]];
return 0;
}
[d release];
}
[l release];
}
return NSApplicationMain(argc, (const char **)argv);
}