-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTweak.x
49 lines (40 loc) · 1.21 KB
/
Tweak.x
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
49
#import "FLEXManager.h"
%group Keyboard
%hook mainVC
- (NSArray<UIKeyCommand *> *)keyCommands
{
NSArray<UIKeyCommand *> *orig = %orig;
UIKeyCommand* flexKeyCommand = [UIKeyCommand keyCommandWithInput:@"f" modifierFlags:UIKeyModifierAlternate action:@selector(flexKeyPressed:)];
if(orig)
{
return [orig arrayByAddingObject:flexKeyCommand];
}
else
{
return @[flexKeyCommand];
}
}
%new
- (void)flexKeyPressed:(id)sender
{
[[FLEXManager sharedManager] showExplorer];
}
%end
%end
void appOrSceneLoaded(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo)
{
Class mainVC = [UIApplication sharedApplication].keyWindow.rootViewController.class;
if(mainVC)
{
static dispatch_once_t onceToken;
dispatch_once (&onceToken, ^
{
%init(Keyboard, mainVC=mainVC);
});
}
}
%ctor
{
CFNotificationCenterAddObserver(CFNotificationCenterGetLocalCenter(), NULL, appOrSceneLoaded, CFSTR("UIApplicationDidFinishLaunchingNotification"), NULL, CFNotificationSuspensionBehaviorCoalesce);
CFNotificationCenterAddObserver(CFNotificationCenterGetLocalCenter(), NULL, appOrSceneLoaded, CFSTR("UISceneWillConnectNotification"), NULL, CFNotificationSuspensionBehaviorCoalesce);
}