mirror of
https://github.com/munki/munki.git
synced 2026-05-12 15:28:51 -05:00
Address an issue with munki-notifier, 'obnoxious mode', and multiple spaces (See https://github.com/munki/munki/issues/1108)
This commit is contained in:
+3
@@ -180,6 +180,9 @@ class MainWindowController: NSWindowController, NSWindowDelegate, WKNavigationDe
|
||||
// makes this app and window impossible(?)/difficult to ignore
|
||||
msc_log("msc", "start_obnoxious_mode")
|
||||
|
||||
// make sure we're frontmost
|
||||
NSApp.activate(ignoringOtherApps: true)
|
||||
|
||||
// make it very difficult to switch away from this app
|
||||
NSApp.presentationOptions = NSApp.currentSystemPresentationOptions.union(
|
||||
NSApplication.PresentationOptions([.hideDock, .disableHideApplication, .disableProcessSwitching, .disableForceQuit]))
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#import <UserNotifications/UserNotifications.h>
|
||||
|
||||
NSString * const NotificationCenterUIBundleID = @"com.apple.notificationcenterui";
|
||||
NSString * const MunkiAppURL = @"munki://";
|
||||
NSString * const MunkiNotificationURL = @"munki://notify";
|
||||
long const DefaultUseNotificationCenterDays = 3;
|
||||
|
||||
@@ -113,6 +114,10 @@ long const DefaultUseNotificationCenterDays = 3;
|
||||
// to launch MSC.app
|
||||
[[NSUserNotificationCenter defaultUserNotificationCenter] removeAllDeliveredNotifications];
|
||||
}
|
||||
// work around a bug with multiple spaces by opening the
|
||||
// app first, sleeping, then telling the app to notify
|
||||
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString: MunkiAppURL]];
|
||||
sleep(1);
|
||||
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString: MunkiNotificationURL]];
|
||||
[NSApp terminate: self];
|
||||
return;
|
||||
@@ -147,16 +152,11 @@ long const DefaultUseNotificationCenterDays = 3;
|
||||
message = deadlineMessage;
|
||||
}
|
||||
|
||||
// Create options (userInfo) dictionary
|
||||
NSMutableDictionary *options = [NSMutableDictionary dictionary];
|
||||
options[@"action"] = @"open_url";
|
||||
options[@"value"] = MunkiNotificationURL;
|
||||
|
||||
// deliver the notification
|
||||
[self deliverNotificationWithTitle:title
|
||||
subtitle:subtitle
|
||||
message:message
|
||||
options:options
|
||||
options:nil
|
||||
sound:nil];
|
||||
}
|
||||
|
||||
@@ -256,8 +256,14 @@ long const DefaultUseNotificationCenterDays = 3;
|
||||
NSLog(@" value: %@", value);
|
||||
|
||||
if ([action isEqualToString:@"open_url"]){
|
||||
// this option currently unused
|
||||
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:value]];
|
||||
} else {
|
||||
// tell MSC app to notify user of updates
|
||||
// work around a bug with multiple spaces by opening the
|
||||
// app first, sleeping, then telling the app to notify
|
||||
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString: MunkiAppURL]];
|
||||
sleep(1);
|
||||
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString: MunkiNotificationURL]];
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>2.0</string>
|
||||
<string>2.1.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
|
||||
Reference in New Issue
Block a user