wireguard-apple icon indicating copy to clipboard operation
wireguard-apple copied to clipboard

Handle dock icon click to open Tunnel Manager (`applicationShouldHandleReopen`)

Open luckman212 opened this issue 2 years ago • 8 comments

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

luckman212 avatar Oct 26 '22 21:10 luckman212

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.

image

Any thoughts from anyone else?

luckman212 avatar Nov 11 '22 15:11 luckman212

Now that macOS development has somewhat resumed, wondering if anyone has some thoughts on this one?

luckman212 avatar Mar 01 '23 20:03 luckman212

I've just added a commit removing the "?". It works as expected by opening the Tunnel Manager when reopened.

sebastianlivoni avatar Jul 01 '23 17:07 sebastianlivoni

@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...

luckman212 avatar Jul 01 '23 18:07 luckman212

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

sebastianlivoni avatar Jul 01 '23 18:07 sebastianlivoni

@zx2c4 or @protonjohn Any chance of this fix making it to the AppStore version?

luckman212 avatar Oct 30 '23 19:10 luckman212