wireguard-apple
wireguard-apple copied to clipboard
Handle dock icon click to open Tunnel Manager (`applicationShouldHandleReopen`)
One thing that bugs me about the WireGuard macOS app is that clicking on its Dock icon does not open the Tunnel Manager window. This is non macOS-like, and limits the ability to show that window programatically via shell scripts, AppleScript, JXA, Alfred etc.
My poor-man's kludge to automate this is to literally quit the app and re-open it, like this (JXA):
function run(argv) {
var WG = new Application("WireGuard");
WG.quit();
WG.activate();
return;
}
...but that's embarrassingly inefficient. I believe after looking at the code that it's because there's no applicationShouldHandleReopen()
func handler.
So this is not a full working PR, just a bit of starter code I was hoping to get refined into a working fix. I do believe the fix is small and fairly easy to implement.
References:
- https://developer.apple.com/documentation/appkit/nsapplicationdelegate/1428638-applicationshouldhandlereopen
- https://developer.apple.com/forums/thread/706772?answerId=715063022#715063022
Unfortunately I can't even build this to test it myself since I don't have a paid Developer account, and without that Apple deems me unfit to produce a Network Extension.

Any thoughts from anyone else?
Now that macOS development has somewhat resumed, wondering if anyone has some thoughts on this one?
I've just added a commit removing the "?". It works as expected by opening the Tunnel Manager when reopened.
@sebastianlivoni Nice. Does it build "as-is" using Xcode14? I haven't tried recently, but when I tried some months ago I didn't have a Developer license (I do now) so I couldn't build the NetworkExtension...
Yep, it does built "as-is". I just had to add the following PATH to "Build Settings" because I'm using M1:
PATH = ${PATH}:/opt/homebrew/opt/[email protected]/bin
@zx2c4 or @protonjohn Any chance of this fix making it to the AppStore version?