diff --git a/MacMediaKeyForwarder/AppDelegate.m b/MacMediaKeyForwarder/AppDelegate.m index 3dc5afb..a93388c 100755 --- a/MacMediaKeyForwarder/AppDelegate.m +++ b/MacMediaKeyForwarder/AppDelegate.m @@ -285,8 +285,12 @@ - (void)applicationDidBecomeActive:(NSNotification *)notification - ( void ) applicationDidFinishLaunching : ( NSNotification*) theNotification { + // Prevent macOS Automatic Termination from killing this windowless menu bar app + [[NSProcessInfo processInfo] disableAutomaticTermination:@"Media key forwarding active"]; + [[NSProcessInfo processInfo] disableSuddenTermination]; + // init containers - + priorityOptionItems = [[NSMutableArray alloc] init]; pauseOptionItems = [[NSMutableArray alloc] init]; @@ -422,7 +426,6 @@ - ( void ) startEventSession { if (pauseState != PauseStatePause && !CFRunLoopContainsSource(CFRunLoopGetCurrent(), eventPortSource, kCFRunLoopCommonModes)) { CFRunLoopAddSource( CFRunLoopGetCurrent(), eventPortSource, kCFRunLoopCommonModes ); - CFRunLoopRun(); } } @@ -430,7 +433,6 @@ - ( void ) stopEventSession { if (CFRunLoopContainsSource(CFRunLoopGetCurrent(), eventPortSource, kCFRunLoopCommonModes)) { CFRunLoopRemoveSource( CFRunLoopGetCurrent(), eventPortSource, kCFRunLoopCommonModes ); - CFRunLoopStop(CFRunLoopGetCurrent()); } }