├── README.md ├── Lifeguard.plist ├── lifeguardprefs ├── Resources │ ├── icons │ │ ├── globe.png │ │ ├── mail.png │ │ ├── plus.png │ │ ├── globe@2x.png │ │ ├── mail@2x.png │ │ ├── plus@2x.png │ │ ├── twitter.png │ │ ├── lifeguard.png │ │ ├── twitter@2x.png │ │ └── lifeguard@2x.png │ ├── Info.plist │ └── Root.plist ├── Makefile ├── entry.plist ├── LGUARDRootListController.h └── LGUARDRootListController.m ├── Lifeguard.h ├── Makefile ├── control └── Tweak.xm /README.md: -------------------------------------------------------------------------------- 1 | # Lifeguard 2 | -------------------------------------------------------------------------------- /Lifeguard.plist: -------------------------------------------------------------------------------- 1 | { Filter = { Bundles = ( "com.apple.springboard" ); }; } 2 | -------------------------------------------------------------------------------- /lifeguardprefs/Resources/icons/globe.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kurrt/Lifeguard/HEAD/lifeguardprefs/Resources/icons/globe.png -------------------------------------------------------------------------------- /lifeguardprefs/Resources/icons/mail.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kurrt/Lifeguard/HEAD/lifeguardprefs/Resources/icons/mail.png -------------------------------------------------------------------------------- /lifeguardprefs/Resources/icons/plus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kurrt/Lifeguard/HEAD/lifeguardprefs/Resources/icons/plus.png -------------------------------------------------------------------------------- /lifeguardprefs/Resources/icons/globe@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kurrt/Lifeguard/HEAD/lifeguardprefs/Resources/icons/globe@2x.png -------------------------------------------------------------------------------- /lifeguardprefs/Resources/icons/mail@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kurrt/Lifeguard/HEAD/lifeguardprefs/Resources/icons/mail@2x.png -------------------------------------------------------------------------------- /lifeguardprefs/Resources/icons/plus@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kurrt/Lifeguard/HEAD/lifeguardprefs/Resources/icons/plus@2x.png -------------------------------------------------------------------------------- /lifeguardprefs/Resources/icons/twitter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kurrt/Lifeguard/HEAD/lifeguardprefs/Resources/icons/twitter.png -------------------------------------------------------------------------------- /lifeguardprefs/Resources/icons/lifeguard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kurrt/Lifeguard/HEAD/lifeguardprefs/Resources/icons/lifeguard.png -------------------------------------------------------------------------------- /lifeguardprefs/Resources/icons/twitter@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kurrt/Lifeguard/HEAD/lifeguardprefs/Resources/icons/twitter@2x.png -------------------------------------------------------------------------------- /lifeguardprefs/Resources/icons/lifeguard@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kurrt/Lifeguard/HEAD/lifeguardprefs/Resources/icons/lifeguard@2x.png -------------------------------------------------------------------------------- /Lifeguard.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface Lifeguard: NSObject 5 | -(id)init; 6 | -(void)buttonPressed_LG:(char) button; 7 | -(void)respring_LG:(BOOL)safeMode; 8 | @end 9 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | export ARCHS = armv7 armv7s arm64 arm64e 2 | export TARGET = iphone:clang:11.2:10.0 3 | 4 | include $(THEOS)/makefiles/common.mk 5 | 6 | TWEAK_NAME = Lifeguard 7 | Lifeguard_FILES = Tweak.xm 8 | 9 | include $(THEOS_MAKE_PATH)/tweak.mk 10 | 11 | after-install:: 12 | install.exec "killall -9 SpringBoard" 13 | SUBPROJECTS += lifeguardprefs 14 | include $(THEOS_MAKE_PATH)/aggregate.mk 15 | -------------------------------------------------------------------------------- /control: -------------------------------------------------------------------------------- 1 | Package: com.kurrt.lifeguard 2 | Name: Lifeguard 3 | Depends: mobilesubstrate 4 | Version: 1.2 5 | Architecture: iphoneos-arm 6 | Description: Respring your device using the hardware buttons. 7 | Homepage: https://kurrt.com/repo/lifeguard 8 | Depiction: https://kurrt.com/repo/lifeguard 9 | SileoDepiction: https://kurrt.com/repo/lifeguard/sileo.php 10 | Maintainer: Kurrt 11 | Author: Kurrt 12 | Section: Tweaks -------------------------------------------------------------------------------- /lifeguardprefs/Makefile: -------------------------------------------------------------------------------- 1 | include $(THEOS)/makefiles/common.mk 2 | 3 | BUNDLE_NAME = LifeguardPrefs 4 | LifeguardPrefs_FILES = LGUARDRootListController.m 5 | LifeguardPrefs_INSTALL_PATH = /Library/PreferenceBundles 6 | LifeguardPrefs_FRAMEWORKS = UIKit 7 | LifeguardPrefs_PRIVATE_FRAMEWORKS = Preferences 8 | 9 | include $(THEOS_MAKE_PATH)/bundle.mk 10 | 11 | internal-stage:: 12 | $(ECHO_NOTHING)mkdir -p $(THEOS_STAGING_DIR)/Library/PreferenceLoader/Preferences$(ECHO_END) 13 | $(ECHO_NOTHING)cp entry.plist $(THEOS_STAGING_DIR)/Library/PreferenceLoader/Preferences/LifeguardPrefs.plist$(ECHO_END) 14 | -------------------------------------------------------------------------------- /lifeguardprefs/entry.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | entry 6 | 7 | bundle 8 | LifeguardPrefs 9 | cell 10 | PSLinkCell 11 | detail 12 | LGUARDRootListController 13 | icon 14 | icons/lifeguard.png 15 | isController 16 | 17 | label 18 | Lifeguard 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /lifeguardprefs/Resources/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | LifeguardPrefs 9 | CFBundleIdentifier 10 | com.kurrt.lifeguardprefs 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | BNDL 15 | CFBundleShortVersionString 16 | 1.0.0 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | 1.0 21 | NSPrincipalClass 22 | LGUARDRootListController 23 | 24 | 25 | -------------------------------------------------------------------------------- /lifeguardprefs/LGUARDRootListController.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | #import 4 | #import 5 | 6 | @interface LGUARDRootListController : PSListController 7 | -(NSArray *)specifiers; 8 | -(void)save; 9 | -(void)email; 10 | -(void)twitter; 11 | -(void)website; 12 | -(void)more; 13 | @end 14 | 15 | 16 | @protocol PreferencesTableCustomView 17 | - (id)initWithSpecifier:(PSSpecifier *)specifier; 18 | - (CGFloat)preferredHeightForWidth:(CGFloat)width; 19 | @end 20 | 21 | @interface LifeguardBigTextCell : PSTableCell { 22 | UILabel *_label; 23 | } 24 | @end 25 | 26 | @interface PSControlTableCell : PSTableCell 27 | - (UIControl *)control; 28 | @end 29 | @interface PSSwitchTableCell : PSControlTableCell 30 | - (id)initWithStyle:(int)style reuseIdentifier:(id)identifier specifier:(id)specifier; 31 | @end 32 | 33 | @interface LifeguardSRSwitchTableCell : PSSwitchTableCell 34 | @end 35 | 36 | @interface LifeguardColorButtonCell : PSTableCell 37 | @end -------------------------------------------------------------------------------- /Tweak.xm: -------------------------------------------------------------------------------- 1 | #import "Lifeguard.h" 2 | 3 | static NSString *respringSequence = @"UDUD"; 4 | static NSString *safeModeSequence = @"SSUDUD"; 5 | static id lifeguardInstance; 6 | static BOOL tweakEnabled = YES; 7 | static BOOL isRunning = NO; 8 | 9 | static void triggerLifeguard(char button) { 10 | if (tweakEnabled && !isRunning) { 11 | isRunning = YES; 12 | if (!lifeguardInstance) lifeguardInstance = [[Lifeguard alloc] init]; 13 | [lifeguardInstance buttonPressed_LG:button]; 14 | isRunning = NO; 15 | } 16 | } 17 | 18 | %hook SpringBoard 19 | 20 | -(void)_ringerChanged:(struct __IOHIDEvent *)arg1 { 21 | triggerLifeguard('S'); 22 | %orig; 23 | } 24 | 25 | -(_Bool)_handlePhysicalButtonEvent:(UIPressesEvent *)arg1 { 26 | int type = arg1.allPresses.allObjects[0].type; 27 | int force = arg1.allPresses.allObjects[0].force; 28 | 29 | // type = 101 -> Home button 30 | // type = 104 -> Power button 31 | // 102 and 103 are volume buttons 32 | 33 | // force = 0 -> button released 34 | // force = 1 -> button pressed 35 | if (force == 1) { 36 | if (type == 103) 37 | triggerLifeguard('D'); 38 | else if (type == 102) 39 | triggerLifeguard('U'); 40 | else if (type == 104) 41 | triggerLifeguard('L'); 42 | else if (type == 101) 43 | triggerLifeguard('H'); 44 | } 45 | return %orig; 46 | } 47 | 48 | %end 49 | 50 | 51 | @implementation Lifeguard 52 | 53 | NSMutableString *sequence = [@"" mutableCopy]; 54 | NSTimeInterval lastPress; 55 | 56 | -(id)init { 57 | lastPress = 0.0; 58 | return self; 59 | } 60 | 61 | -(void)buttonPressed_LG:(char)button { 62 | 63 | NSTimeInterval now = [[NSDate date] timeIntervalSince1970] * 1000; 64 | if (now - lastPress > 650.0) 65 | [sequence setString:@""]; 66 | lastPress = now; 67 | 68 | [sequence appendFormat:@"%c", button]; 69 | if ([respringSequence length] >= [safeModeSequence length]) { 70 | if ([[sequence copy] containsString: respringSequence]) 71 | [self respring_LG:NO]; 72 | else if ([[sequence copy] containsString: safeModeSequence]) 73 | [self respring_LG:YES]; 74 | } else { 75 | if ([[sequence copy] containsString: safeModeSequence]) 76 | [self respring_LG:YES]; 77 | else if ([[sequence copy] containsString: respringSequence]) 78 | [self respring_LG:NO]; 79 | } 80 | } 81 | 82 | -(void)respring_LG:(BOOL)safeMode { 83 | [sequence setString:@""]; 84 | pid_t pid; 85 | if (safeMode) { 86 | const char* args[] = {"killall", "-SEGV", "SpringBoard", NULL}; 87 | posix_spawn(&pid, "/usr/bin/killall", NULL, NULL, (char* const*)args, NULL); 88 | } else { 89 | const char* args[] = {"killall", "backboardd", NULL}; 90 | posix_spawn(&pid, "/usr/bin/killall", NULL, NULL, (char* const*)args, NULL); 91 | } 92 | } 93 | 94 | @end 95 | 96 | 97 | 98 | static void loadPrefs() { 99 | NSMutableDictionary *prefs = [[NSMutableDictionary alloc] initWithContentsOfFile:@"/var/mobile/Library/Preferences/com.kurrt.lifeguardprefs.plist"]; 100 | if(prefs) { 101 | tweakEnabled = ([prefs objectForKey:@"tweakEnabled"] ? [[prefs objectForKey:@"tweakEnabled"] boolValue] : tweakEnabled); 102 | respringSequence = [(NSString*)[prefs objectForKey:@"respringSequence"] uppercaseString]; 103 | safeModeSequence = [(NSString*)[prefs objectForKey:@"safeModeSequence"] uppercaseString]; 104 | if ([respringSequence length] <= 0) respringSequence = @"X"; 105 | if ([safeModeSequence length] <= 0) safeModeSequence = @"X"; 106 | } 107 | [prefs release]; 108 | } 109 | 110 | %ctor { 111 | CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (CFNotificationCallback)loadPrefs, CFSTR("com.kurrt.lifeguardprefs/settingschanged"), NULL, CFNotificationSuspensionBehaviorCoalesce); 112 | loadPrefs(); 113 | } 114 | 115 | -------------------------------------------------------------------------------- /lifeguardprefs/Resources/Root.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | items 6 | 7 | 8 | cell 9 | PSGroupCell 10 | label 11 | Settings 12 | 13 | 14 | cell 15 | PSSwitchCell 16 | default 17 | 18 | defaults 19 | com.kurrt.lifeguardprefs 20 | key 21 | tweakEnabled 22 | id 23 | enableSwitch 24 | label 25 | Tweak Enabled 26 | cellClass 27 | LifeguardSRSwitchTableCell 28 | PostNotification 29 | com.kurrt.lifeguardprefs/settingschanged 30 | 31 | 32 | cell 33 | PSGroupCell 34 | label 35 | Button Sequences 36 | footerCellClass 37 | LifeguardBigTextCell 38 | 39 | 40 | cell 41 | PSEditTextCell 42 | label 43 | Respring: 44 | noAutoCorrect 45 | 46 | default 47 | UDUD 48 | defaults 49 | com.kurrt.lifeguardprefs 50 | key 51 | respringSequence 52 | PostNotification 53 | com.kurrt.lifeguardprefs/settingschanged 54 | 55 | 56 | cell 57 | PSEditTextCell 58 | label 59 | Safe Mode: 60 | noAutoCorrect 61 | 62 | default 63 | SSUDUD 64 | defaults 65 | com.kurrt.lifeguardprefs 66 | key 67 | safeModeSequence 68 | PostNotification 69 | com.kurrt.lifeguardprefs/settingschanged 70 | 71 | 72 | cell 73 | PSGroupCell 74 | label 75 | More 76 | 77 | 78 | cell 79 | PSButtonCell 80 | label 81 | More Tweaks by Kurrt 82 | action 83 | more 84 | hasIcon 85 | 86 | icon 87 | icons/plus.png 88 | cellClass 89 | LifeguardColorButtonCell 90 | 91 | 92 | cell 93 | PSGroupCell 94 | label 95 | Support 96 | 97 | 98 | cell 99 | PSButtonCell 100 | label 101 | Follow @KurrtDev on Twitter 102 | action 103 | twitter 104 | hasIcon 105 | 106 | icon 107 | icons/twitter.png 108 | cellClass 109 | LifeguardColorButtonCell 110 | 111 | 112 | cell 113 | PSButtonCell 114 | label 115 | Kurrt.com 116 | action 117 | website 118 | hasIcon 119 | 120 | icon 121 | icons/globe.png 122 | cellClass 123 | LifeguardColorButtonCell 124 | 125 | 126 | cell 127 | PSButtonCell 128 | label 129 | Email Support 130 | action 131 | email 132 | hasIcon 133 | 134 | icon 135 | icons/mail.png 136 | cellClass 137 | LifeguardColorButtonCell 138 | 139 | 140 | cell 141 | PSGroupCell 142 | footerAlignment 143 | 1 144 | footerText 145 | © 2018 Kurrt (@KurrtDev) 146 | 147 | 148 | title 149 | Lifeguard 150 | 151 | 152 | -------------------------------------------------------------------------------- /lifeguardprefs/LGUARDRootListController.m: -------------------------------------------------------------------------------- 1 | #include "LGUARDRootListController.h" 2 | 3 | static UIColor *defaultTint; 4 | static UIButton *save; 5 | 6 | @implementation LGUARDRootListController 7 | 8 | -(void)viewWillAppear:(BOOL)animated { 9 | [super viewWillAppear:animated]; 10 | UIColor *tintColor = [UIColor redColor]; 11 | UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow; 12 | defaultTint = [keyWindow tintColor]; 13 | [keyWindow setTintColor:tintColor]; 14 | 15 | [[NSNotificationCenter defaultCenter] addObserver:self 16 | selector:@selector(keyboardDidShow:) 17 | name:UIKeyboardWillShowNotification 18 | object:nil]; 19 | } 20 | 21 | - (void) viewWillDisappear:(BOOL)animated { 22 | [super viewWillDisappear:animated]; 23 | if (defaultTint) { 24 | UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow; 25 | [keyWindow setTintColor:defaultTint]; 26 | } 27 | [[NSNotificationCenter defaultCenter] removeObserver: self]; 28 | } 29 | 30 | - (NSArray *)specifiers { 31 | if (!_specifiers) { 32 | _specifiers = [[self loadSpecifiersFromPlistName:@"Root" target:self] retain]; 33 | } 34 | 35 | return _specifiers; 36 | } 37 | 38 | - (id)readPreferenceValue:(PSSpecifier*)specifier { 39 | NSString *path = [NSString stringWithFormat:@"/User/Library/Preferences/%@.plist", specifier.properties[@"defaults"]]; 40 | NSMutableDictionary *settings = [NSMutableDictionary dictionary]; 41 | [settings addEntriesFromDictionary:[NSDictionary dictionaryWithContentsOfFile:path]]; 42 | return (settings[specifier.properties[@"key"]]) ?: specifier.properties[@"default"]; 43 | } 44 | 45 | - (void)setPreferenceValue:(id)value specifier:(PSSpecifier*)specifier { 46 | NSString *path = [NSString stringWithFormat:@"/User/Library/Preferences/%@.plist", specifier.properties[@"defaults"]]; 47 | NSMutableDictionary *settings = [NSMutableDictionary dictionary]; 48 | [settings addEntriesFromDictionary:[NSDictionary dictionaryWithContentsOfFile:path]]; 49 | [settings setObject:value forKey:specifier.properties[@"key"]]; 50 | [settings writeToFile:path atomically:YES]; 51 | CFStringRef notificationName = (CFStringRef)specifier.properties[@"PostNotification"]; 52 | if (notificationName) { 53 | CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), notificationName, NULL, NULL, YES); 54 | } 55 | } 56 | 57 | -(void)save { 58 | [self.view endEditing:YES]; 59 | save.hidden = YES; 60 | } 61 | 62 | 63 | -(void)loadView { 64 | [super loadView]; 65 | save = [[UIButton alloc] initWithFrame:CGRectZero]; 66 | [save setTitle:@"Save" forState:UIControlStateNormal]; 67 | [save sizeToFit]; 68 | [save setTitleColor: [UIColor redColor] forState:UIControlStateNormal]; 69 | [save addTarget:self action:@selector(save) forControlEvents:UIControlEventTouchUpInside]; 70 | save.hidden = YES; 71 | self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:save]; 72 | } 73 | 74 | 75 | -(void) email { 76 | UIApplication *application = [UIApplication sharedApplication]; 77 | NSURL *URL = [NSURL URLWithString:[@"mailto:dev@kurrt.com?subject=Lifeguard Support Request&body=Please provide as mush detail as possible about your request. If you encounter a bug, the more information you provide me, the quicker I am going to be able to fix the bug.
Device Model:
iOS Version:

" stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]]; 78 | [application openURL:URL options:@{} completionHandler:nil]; 79 | } 80 | 81 | -(void) twitter { 82 | UIApplication *application = [UIApplication sharedApplication]; 83 | NSURL *URL = [NSURL URLWithString:@"https://twitter.com/KurrtDev"]; 84 | [application openURL:URL options:@{} completionHandler:nil]; 85 | } 86 | 87 | -(void) website { 88 | UIApplication *application = [UIApplication sharedApplication]; 89 | NSURL *URL = [NSURL URLWithString:@"https://kurrt.com"]; 90 | [application openURL:URL options:@{} completionHandler:nil]; 91 | } 92 | 93 | -(void) more { 94 | UIApplication *application = [UIApplication sharedApplication]; 95 | NSURL *URL = [NSURL URLWithString:@"https://kurrt.com/repo"]; 96 | [application openURL:URL options:@{} completionHandler:nil]; 97 | } 98 | 99 | 100 | - (void)keyboardDidShow: (NSNotification *) notif{ 101 | save.hidden = NO; 102 | } 103 | 104 | 105 | @end 106 | 107 | 108 | @implementation LifeguardBigTextCell 109 | 110 | float cellHeight = 200.0f; 111 | 112 | - (id)initWithSpecifier:(PSSpecifier *)specifier { 113 | self = [super initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell" specifier:specifier]; 114 | if (self) { 115 | _label = [[UILabel alloc] initWithFrame:CGRectMake(16, 16, self.frame.size.width - 32, cellHeight - 48)]; 116 | [_label setLineBreakMode:NSLineBreakByWordWrapping]; 117 | [_label setNumberOfLines:0]; 118 | [_label setText:@"H - Home Button\nL - Lock Button\nU - Volume Up Button\nD - Volume Down Button\nS - Mute Switch\n"]; 119 | [_label sizeToFit]; 120 | [self addSubview:_label]; 121 | [_label release]; 122 | 123 | UILabel *_label2 = [[UILabel alloc] initWithFrame:CGRectMake(16, _label.frame.size.height + 16, self.frame.size.width - 32, cellHeight - 48)]; 124 | [_label2 setLineBreakMode:NSLineBreakByWordWrapping]; 125 | [_label2 setNumberOfLines:0]; 126 | [_label2 setText:@"Define your chosen patterns using the letters above.\ne.g. SSUDUD defines the pattern: [toggle switch] [toggle switch] [volume up] [volume down] [volume up] [volume down]\n\nPatterns are not case sensitive. To disable an option leave the field blank. Use of undefined letters will also disable the option."]; 127 | [_label2 setFont:[UIFont systemFontOfSize:12]]; 128 | [_label2 sizeToFit]; 129 | [self addSubview:_label2]; 130 | [_label2 release]; 131 | 132 | cellHeight = _label.frame.size.height + _label2.frame.size.height + 48; 133 | 134 | } 135 | return self; 136 | } 137 | 138 | - (CGFloat)preferredHeightForWidth:(CGFloat)width { 139 | // Return a custom cell height. 140 | return cellHeight; 141 | } 142 | @end 143 | 144 | 145 | @implementation LifeguardColorButtonCell 146 | -(void) layoutSubviews { 147 | [super layoutSubviews]; 148 | UIColor *tintColor = [UIColor redColor]; 149 | [[self textLabel] setTextColor:tintColor]; 150 | } 151 | @end 152 | 153 | @implementation LifeguardSRSwitchTableCell 154 | 155 | -(id)initWithStyle:(int)style reuseIdentifier:(id)identifier specifier:(id)specifier { //init method 156 | self = [super initWithStyle:style reuseIdentifier:identifier specifier:specifier]; 157 | UIColor *tintColor = [UIColor redColor]; 158 | if (self) { 159 | [((UISwitch *)[self control]) setOnTintColor:tintColor]; 160 | } 161 | return self; 162 | } 163 | 164 | @end --------------------------------------------------------------------------------