Skip to content

Instantly share code, notes, and snippets.

View MTACS's full-sized avatar

D.F. MTACS

View GitHub Profile
@MTACS
MTACS / CarPlayWiredBattery.m
Last active September 26, 2023 17:19
Always show battery icon on wired CarPlay connections
// CAR* classes have been renamed to DB (DashBoard.framework) on iOS 16
// Note that this only shows the default battery with no inline percentage on iOS 16, use a tweak like Ampere (v1.3+) to enable the percentage
// iOS >= 16
%hook DBEnvironmentConfiguration
- (BOOL)isConnectedWirelessly {
return YES;
}
%end
@MTACS
MTACS / SwitcherTerminate.m
Created December 26, 2022 15:38
Kill all running apps iOS 16+
@interface SBAppLayout : NSObject
@end
@interface SBFluidSwitcherItemContainer: UIView
@end
@interface SBFluidSwitcherViewController: UIViewController
@property (readonly, nonatomic) NSArray *appLayouts;
- (id)_itemContainerForAppLayoutIfExists:(id)arg0;
- (void)killContainer:(id)arg0 forReason:(NSInteger)arg1;
@MTACS
MTACS / LPM.m
Last active November 30, 2023 21:45
Toggle Low Power Mode programmatically on iOS 16+
// iOS 16+
// _CDBatterySaver class doesn't exist on versions higher than 16.0
@interface _PMLowPowerMode : NSObject
+ (id)sharedInstance;
- (NSInteger)getPowerMode;
- (void)setPowerMode:(NSInteger)arg0 fromSource:(id)arg1;
- (void)setPowerMode:(NSInteger)arg0 fromSource:(id)arg1 withCompletion:(id)arg2; // Don't use if completion is nil, callback requires non null parameter
@end
@MTACS
MTACS / hosted.md
Last active November 30, 2023 22:16
Hosted Preference bundle

Hosted Preference Bundles

Create a "hosted" view of a preference bundle outside of Preferences.app, and in a dedicated application.

For application

  • Create new tweak using "iphone/application_modern" template
  • In the app's delegate file add the following to the -(void)applicationDidFinishLaunching:(UIApplication *)application; method:
@MTACS
MTACS / Tweak.xm
Created April 13, 2021 03:04
App icon download progress
@interface SBIcon : NSObject
@end
@interface SBLeafIcon : SBIcon
- (id)displayNameForLocation:(id)arg1;
@end
@interface SBIconView: UIView
@property (nonatomic, retain) SBIcon *icon;
- (void)_updateLabel;
@MTACS
MTACS / MenuItems.m
Last active November 20, 2021 11:20
Add custom shortcut item to 3D Touch menus on iOS 13+
// MenuItems.m
// (*.m) for gist formatting
// Makefile
TWEAK_NAME = YourTweak
YourTweak_PRIVATE_FRAMEWORKS = SpringBoardServices
// Tweak.h
@MTACS
MTACS / arm64e-linux.sh
Created October 5, 2020 18:04 — forked from seia-soto/arm64e-linux.sh
Installs sbinger's arm64e toolchain to allow arm64e compilation on Linux
curl -LO https://github.com/sbingner/llvm-project/releases/download/v10.0.0-1/linux-ios-arm64e-clang-toolchain.tar.lzma
TMP=$(mktemp -d)
tar --lzma -xvf linux-ios-arm64e-clang-toolchain.tar.lzma -C $TMP
pushd $TMP/ios-arm64e-clang-toolchain/bin
find * ! -name clang-10 -and ! -name ldid -and ! -name ld64 -exec mv {} arm64-apple-darwin14-{} \;
find * -xtype l -exec sh -c "readlink {} | xargs -I{LINK} ln -f -s arm64-apple-darwin14-{LINK} {}" \;
popd
mkdir -p $THEOS/toolchain/linux/iphone
mv $TMP/ios-arm64e-clang-toolchain/* $THEOS/toolchain/linux/iphone/
rm -rf $TMP linux-ios-arm64e-clang-toolchain.tar.lzma
@interface SBHWidget: NSObject
@property NSString *configurationStorageIdentifier; // com.apple.mobilecal
@property NSString *configurationBundleIdentifier; // com.apple.mobilecal
@property NSString *displayName; // Calendar
@property NSString *extensionBundleIdentifier; // com.apple.mobilecal.CalendarWidgetExtension
@property NSString *kind; // com.apple.CalendarWidget.CalendarWidget
@end
@interface SBWidgetIcon: NSObject
@property SBHWidget *activeWidget;
@MTACS
MTACS / Prefs.m
Created July 13, 2020 18:16
"Fix" for HBRespringController respringAndReturnTo: method freezing
#import "spawn.h"
#import "Prefs.h"
#import <Cephei/HBRespringController.h>
@implementation PrefsController
- (void)respring {
[HBRespringController respringAndReturnTo:[NSURL URLWithString:@"prefs:root=YourPrefs"]];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
@MTACS
MTACS / Prefs.plist
Created February 22, 2020 17:33
Solution to libcolorpicker not saving values
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>items</key>
<array>
<dict>
<key>cell</key>
<string>PSLinkCell</string>
<key>cellClass</key>