macbook-charging-controls
5 views
f4f13f03...
Description
Override MacBook charging smartness
How to Use
Download the script and run it with Frida CLI:
Download ScriptThen run with Frida:
frida -U -f YOUR_PACKAGE_NAME -l macbook-charging-controls.js
Replace YOUR_PACKAGE_NAME with the target app's package name.
Source Code
JavaScript
/*
* Inject into PowerUIAgent (SIP must be disabled)
*/
const {
NSAutoreleasePool,
PowerUISmartChargeManager,
} = ObjC.classes;
let onComplete;
function forceDesktopMode() {
withManager(manager => {
manager.setDesktopMode_withHandler_('DesktopMode', onComplete);
console.log('Forced desktop mode');
});
}
function resetDesktopMode() {
withManager(manager => {
manager.resetDesktopModeWithHandler_(onComplete);
console.log('Reset desktop mode');
});
}
onComplete = new ObjC.Block({
retType: 'void',
argTypes: ['int64'],
implementation(result) {
console.log(`onComplete() result=${result}`);
}
});
function enableCharging() {
withManager(manager => {
manager.enableCharging();
console.log('Enabled charging');
});
}
function disableCharging() {
withManager(manager => {
manager.disableCharging();
console.log('Disabled charging');
});
}
function withManager(work) {
const pool = NSAutoreleasePool.alloc().init();
try {
const manager = PowerUISmartChargeManager.manager();
ObjC.schedule(manager.queue(), () => {
work(manager);
});
} finally {
pool.release();
}
}
Comments