diff options
author | Damiano Galassi <[email protected]> | 2019-06-08 17:46:01 +0200 |
---|---|---|
committer | Damiano Galassi <[email protected]> | 2019-06-08 17:46:01 +0200 |
commit | 727dc9879454c0aea3b2cf4aecbd54d95d8ae45b (patch) | |
tree | dcb787647dde0e6a520e8c834021eceba95999ad /macosx/HBQueueController.m | |
parent | fd2c883de4cea7094c08fed7ea22418ec3472281 (diff) |
MacGui: fix queue sleep and shutdown on 10.14 and under sandbox.
Diffstat (limited to 'macosx/HBQueueController.m')
-rw-r--r-- | macosx/HBQueueController.m | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/macosx/HBQueueController.m b/macosx/HBQueueController.m index bd8564ded..87d0ceefe 100644 --- a/macosx/HBQueueController.m +++ b/macosx/HBQueueController.m @@ -1073,7 +1073,7 @@ static void *HBControllerQueueCoreContext = &HBControllerQueueCoreContext; // Sleep NSDictionary *errorDict; NSAppleScript *scriptObject = [[NSAppleScript alloc] initWithSource: - @"tell application \"Finder\" to sleep"]; + @"tell application \"System Events\" to sleep"]; [scriptObject executeAndReturnError: &errorDict]; } // If Shutdown has been selected @@ -1081,7 +1081,7 @@ static void *HBControllerQueueCoreContext = &HBControllerQueueCoreContext; { // Shut Down NSDictionary *errorDict; - NSAppleScript *scriptObject = [[NSAppleScript alloc] initWithSource:@"tell application \"Finder\" to shut down"]; + NSAppleScript *scriptObject = [[NSAppleScript alloc] initWithSource:@"tell application \"System Events\" to shut down"]; [scriptObject executeAndReturnError: &errorDict]; } } @@ -1219,6 +1219,8 @@ static void *HBControllerQueueCoreContext = &HBControllerQueueCoreContext; { [self.delegate showPreferencesWindow:nil]; } + + [self promptForAppleEventAuthorization]; } else if ([[NSUserDefaults standardUserDefaults] integerForKey:@"HBAlertWhenDone"] == HBDoneActionShutDown) { @@ -1237,6 +1239,17 @@ static void *HBControllerQueueCoreContext = &HBControllerQueueCoreContext; { [self.delegate showPreferencesWindow:nil]; } + + [self promptForAppleEventAuthorization]; + } +} + +- (void)promptForAppleEventAuthorization +{ + HBPrivacyConsentState result = [HBUtilities determinePermissionToAutomateTarget:@"com.apple.systemevents" promptIfNeeded:YES]; + if (result != HBPrivacyConsentStateGranted) + { + [HBUtilities writeToActivityLog:"Failed to get permission to automate system events"]; } } |