Skip to content

Commit

Permalink
Catch SIGTERM signal and fix brightness value storage.
Browse files Browse the repository at this point in the history
  • Loading branch information
Bensge committed Jan 14, 2017
1 parent ac664f4 commit d2bc94c
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions NativeDisplayBrightness/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ - (void)_loadBrightness

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
delegateInstance = self;
if (![self _loadBezelServices])
{
[self _loadOSDFramework];
Expand All @@ -160,10 +161,28 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
[self _checkTrusted];
[self _registerGlobalKeyboardEvents];
[self _loadBrightness];
[self _registerSignalHandling];
}

__weak AppDelegate *delegateInstance = nil;

void shutdownSignalHandler(int signal) {
NSLog(@"Caught SIGTERM");
[delegateInstance _willTerminate];
}

- (void)_registerSignalHandling
{
signal(SIGTERM, shutdownSignalHandler);
}


- (void)applicationWillTerminate:(NSNotification *)aNotification
{
[self _willTerminate];
}

- (void)_willTerminate
{
NSLog(@"willTerminate");
[self _saveBrightness];
Expand Down

0 comments on commit d2bc94c

Please sign in to comment.