// isletctl demo | snap | dump | reset | defaults | get [key] | set // demo: 1 notification, 2 timer, 3 music, 4 charging, 5 silent, 6 clear, 7/8/10 open timer/music/call, 9 call, // 12 airplane, 13 focus, 14 flashlight on, 15 cellular, 16 flashlight off, 17 recording, 18 Bluetooth pill, // 19 AirPods, 20 Watch low battery, 21 iPhone low battery, 22 fully charged, 23 calendar, 24 hide, 25 low power, 26 unlock, // 27 hotspot, 28 mirroring, 29 microphone, 30 volume, 31 ring bell, 32 rotation lock, 33 AirDrop, 34 headphones bubble, 35 Watch ping, 36 lyrics #import #import #import #import "common.h" static id ParseValue(const char *v) { if (!strcmp(v, "true") || !strcmp(v, "on")) return @YES; if (!strcmp(v, "false") || !strcmp(v, "off")) return @NO; char *end; double d = strtod(v, &end); return *end ? (id)NS(v) : (id)@(d); } int main(int argc, char **argv) { if (argc >= 3 && !strcmp(argv[1], "demo")) { int t; notify_register_check("com.astar76.islet.demo", &t); notify_set_state(t, atoi(argv[2])); notify_post("com.astar76.islet.demo"); return 0; } if (argc >= 2 && !strcmp(argv[1], "reset")) { [NSFileManager.defaultManager removeItemAtPath:GUARD_PATH error:nil]; return 0; } if (argc >= 2 && !strcmp(argv[1], "defaults")) { [NSFileManager.defaultManager removeItemAtPath:PREFS_PATH error:nil]; notify_post(PREFS_NOTIFICATION); return 0; } if (argc >= 2 && !strcmp(argv[1], "dump")) { notify_post("com.astar76.islet.dump"); return 0; } if (argc >= 2 && !strcmp(argv[1], "snap")) { notify_post("com.astar76.islet.snap"); return 0; } if (argc >= 2 && !strcmp(argv[1], "get")) { NSDictionary *d = [NSDictionary dictionaryWithContentsOfFile:PREFS_PATH]; printf("%s\n", [[NSString stringWithFormat:@"%@", argc >= 3 ? d[NS(argv[2])] : d] UTF8String]); return 0; } if (argc >= 4 && !strcmp(argv[1], "set")) { NSMutableDictionary *d = [NSMutableDictionary dictionaryWithContentsOfFile:PREFS_PATH] ?: [NSMutableDictionary new]; d[NS(argv[2])] = ParseValue(argv[3]); if (![d writeToFile:PREFS_PATH atomically:YES]) { fprintf(stderr, "can't write prefs\n"); return 1; } notify_post(PREFS_NOTIFICATION); return 0; } fprintf(stderr, "usage: isletctl demo <1-36> | snap | dump | reset | defaults | get [key] | set \n"); return 1; }