|
26 | 26 | import java.awt.event.ActionListener; |
27 | 27 | import java.lang.reflect.Field; |
28 | 28 | import java.lang.reflect.Method; |
| 29 | +import java.net.URI; |
29 | 30 | import java.nio.file.Files; |
30 | 31 | import java.nio.file.Path; |
31 | 32 | import java.util.ArrayList; |
@@ -68,6 +69,28 @@ public static void registerAboutDialog(Dialog aboutDialog) { |
68 | 69 | } |
69 | 70 | } |
70 | 71 |
|
| 72 | + /** |
| 73 | + * Configure macOS to intercept URIs when app is running |
| 74 | + * See also: https://github.com/qzind/tray/issues/850 |
| 75 | + */ |
| 76 | + public static void registerUriHandler() { |
| 77 | + Desktop.getDesktop().setOpenURIHandler(e -> { |
| 78 | + // TODO: Filter for "qz:launch" |
| 79 | + URI uri = e.getURI(); |
| 80 | + log.warn("Scheme: {}, Host: {}, Path: {}, ", uri.getScheme(), uri.getHost(), uri.getPath()); |
| 81 | + //if(uri.getScheme().equals(Constants.DATA_DIR)) { |
| 82 | + //if(uri.getScheme().equals()) { |
| 83 | + ShellUtilities.execute("/usr/bin/open", |
| 84 | + // Open a new instance of the application even if one is already running. |
| 85 | + "-n", |
| 86 | + // Opens the specified application. |
| 87 | + "-a", Constants.ABOUT_TITLE, |
| 88 | + // All remaining arguments are passed to the opened application in the argv parameter to main(). |
| 89 | + // These arguments are not opened or interpreted by the open tool. |
| 90 | + "--args", ArgValue.STEAL.getMatch()); |
| 91 | + }); |
| 92 | + } |
| 93 | + |
71 | 94 | /** |
72 | 95 | * Calculates CFBundleIdentifier for macOS |
73 | 96 | * @return |
@@ -113,7 +136,7 @@ public static void registerQuitHandler(TrayManager trayManager) { |
113 | 136 | } |
114 | 137 |
|
115 | 138 | /** |
116 | | - * Runs a shell command to determine if "Dark" desktop theme is enabled |
| 139 | + * Runs a shell command to determine if "Dark" top theme is enabled |
117 | 140 | * @return true if enabled, false if not |
118 | 141 | */ |
119 | 142 | public static boolean isDarkDesktop() { |
|
0 commit comments