-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTweak.xm
More file actions
47 lines (34 loc) · 1.38 KB
/
Copy pathTweak.xm
File metadata and controls
47 lines (34 loc) · 1.38 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#import "libactivator.h"
#import "headers.h"
static SpringBoard *springBoard = nil;
@interface LAHomer : NSObject <LAListener, UIAlertViewDelegate>
@end
NSMutableDictionary *prefs = [[NSMutableDictionary alloc] initWithContentsOfFile:@"/var/mobile/Library/Preferences/com.johnmatula.homerrr.plist"];
/*NSString* commandToRun = [[prefs objectForKey:@"commandToRun"] boolValue];*/
NSString *commandToRun = [prefs objectForKey:@"commandToRun"];
BOOL preventDefault = [[prefs objectForKey:@"preventDefault"] boolValue];
@implementation LAHomer
- (void)activator:(LAActivator *)activator receiveDeactivateEvent:(LAEvent *)event {
system([commandToRun UTF8String]);
if(preventDefault) {
[event setHandled:YES]; // To prevent the default OS implementation
}
}
- (void)openURL:(NSURL *)URL {
if ([springBoard respondsToSelector:@selector(openURL:)]) {
[springBoard openURL:URL];
} else if ([springBoard respondsToSelector:@selector(applicationOpenURL:)]) {
[springBoard applicationOpenURL:URL publicURLsOnly:NO animating:YES];
}
}
+ (void)load {
if ([[[NSBundle mainBundle] bundleIdentifier] isEqualToString:@"com.apple.springboard"])
[[%c(LAActivator) sharedInstance] registerListener:[self new] forName:@"com.johnmatula.homerrr"];
}
@end
%hook SpringBoard
- (void)applicationDidFinishLaunching:(id)fp8 {
%orig;
springBoard = self;
}
%end