BangleApps/apps/drained/boot.ts

22 lines
528 B
TypeScript
Raw Normal View History

{
2023-05-07 09:36:31 +00:00
const { battery: threshold = 5, interval = 10, keepStartup = true }: DrainedSettings
= require("Storage").readJSON(`drained.setting.json`, true) || {};
drainedInterval = setInterval(() => {
2023-03-10 23:20:28 +00:00
if(Bangle.isCharging())
return;
2023-04-13 17:30:49 +00:00
if(E.getBattery() > threshold)
2023-03-10 23:20:28 +00:00
return;
const app = "drained.app.js";
2023-05-07 09:36:31 +00:00
if(!keepStartup)
require("Storage").write(
".boot0",
`if(typeof __FILE__ === "undefined" || __FILE__ !== "${app}") setTimeout(load, 100, "${app}");`
);
2023-04-13 17:30:49 +00:00
load(app);
}, interval * 60 * 1000);
}