From 74c750b8ac0cf2dbfd0169faacba15dc9d271503 Mon Sep 17 00:00:00 2001 From: Raafat Akkad Date: Wed, 5 Jul 2023 19:51:21 +0100 Subject: [PATCH] Exit if no fans are detected --- Classes/FanControl.m | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Classes/FanControl.m b/Classes/FanControl.m index 0508033..d31e759 100755 --- a/Classes/FanControl.m +++ b/Classes/FanControl.m @@ -52,18 +52,29 @@ +(void) initialize { //avoid Zombies when starting external app signal(SIGCHLD, SIG_IGN); - [FanControl copyMachinesIfNecessary]; //check owner and suid rights [FanControl setRights]; //talk to smc [smcWrapper init]; + [FanControl terminateIfNoFans]; + + [FanControl copyMachinesIfNecessary]; + //app in foreground for update notifications [[NSApplication sharedApplication] activateIgnoringOtherApps:YES]; } ++(void) terminateIfNoFans { + int fan_num = [smcWrapper get_fan_num]; + if (fan_num <= 0) { + NSLog(@"Exiting as %d fans were detected for Model Identifier: %@", fan_num, [MachineDefaults computerModel]); + [[NSApplication sharedApplication] terminate:self]; + } +} + +(void)copyMachinesIfNecessary { NSString *path = [[[NSFileManager defaultManager] applicationSupportDirectory] stringByAppendingPathComponent:@"Machines.plist"];