Skip to content

Commit

Permalink
Add NSUserActivityTypeBrowsingWeb handling
Browse files Browse the repository at this point in the history
  • Loading branch information
mdbraber authored and cmsj committed Aug 18, 2024
1 parent 45fa356 commit a86a3f4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions Hammerspoon/Hammerspoon-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@
<key>NSUserActivityTypes</key>
<array>
<string>HSExecuteLuaIntent</string>
<string>NSUserActivityTypeBrowsingWeb</string>
</array>
<key>NSUserNotificationAlertStyle</key>
<string>alert</string>
Expand Down
12 changes: 12 additions & 0 deletions Hammerspoon/MJAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ - (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)fileAnd
}
}


success = [[NSFileManager defaultManager] moveItemAtPath:fileAndPath toPath:dstSpoonFullPath error:&fileError];
if (!success) {
NSLog(@"Unable to move %@ to %@: %@", fileAndPath, spoonPath, fileError);
Expand Down Expand Up @@ -129,6 +130,17 @@ - (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)fileAnd
return YES;
}

- (BOOL)application:(NSApplication *)application
continueUserActivity:(NSUserActivity *)userActivity
restorationHandler:(nonnull void (^)(NSArray<id<NSUserActivityRestoring>> *_Nullable))restorationHandler
{
//NSLog(@"Open URL in NSUserActivityTypeBrowsingWeb");
if ([userActivity.activityType isEqualToString:NSUserActivityTypeBrowsingWeb]) {
[[NSWorkspace sharedWorkspace] openURL:userActivity.webpageURL];
}
return YES;
}


- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
BOOL isTesting = NO;
Expand Down

0 comments on commit a86a3f4

Please sign in to comment.