Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Opening with Chrome App Shortcuts causing infinite loop / not working #153

Closed
skoshy opened this issue Nov 25, 2020 · 10 comments
Closed

Opening with Chrome App Shortcuts causing infinite loop / not working #153

skoshy opened this issue Nov 25, 2020 · 10 comments
Labels

Comments

@skoshy
Copy link
Contributor

skoshy commented Nov 25, 2020

If I try specifying a direct path to a Chrome App Shortcut (generated through Chrome Menu -> More Tools -> Create application shortcut), it causes an infinite loop of opening the window and doesn't actually go to the correct URL within the app as well.

Google Meet is a good example; if you have a Chrome App of https://meet.google.com and try clicking a Google Meet link from somewhere else, this behavior occurs.

Here's my config:

const googleMeetApp = {
  browser: {
    name: '/Users/xxxxxx/Applications/Chrome Apps.localized/Meet.app',
    appType: 'appPath',
  },
}

module.exports = {
  defaultBrowser: "Google Chrome",
  rewrite: [
    {
      // Redirect all urls to use https
      match: ({ url }) => url.protocol === "http",
      url: { protocol: "https" }
    }
  ],
  handlers: [
    {
      match: finicky.matchHostnames(['meet.google.com']),
      ...googleMeetApp,
    },
    // ...
  ]
};
@johnste
Copy link
Owner

johnste commented Jan 28, 2021

Hm not seeing the "Create application shortcut" menu item for google meet. There is a "Create shortcut" option but all it seems to do is to open up a normal tab in Chrome.

I did find an "install" option when I tried https://excalidraw.com/ which I might be able to use. It installs an app (does not open a browser window). I will try using that first.

@skoshy
Copy link
Contributor Author

skoshy commented Jan 31, 2021

No problem @johnste , this issue is actually solved with PR #160 that I submitted a while ago.

Here's how I created an app shortcut for Google Meet:

image

I then opened the Google Meet.app package and checked the Info.plist inside to get the app ID (mine was jhgifngagadhdmngcahhimadjfofillb).

I then set up Finicky like so:

const googleMeetApp = {
  browser: ({ urlString }) => ({
    name: "Google Chrome",
    profile: "Profile 13", // use whatever profile created the application shortcut
    args: [
      `--app-id=jhgifngagadhdmngcahhimadjfofillb`, // my app ID for my Google Meet application shortcut
      `--app-launch-url-for-shortcuts-menu-item=${urlString}`,
      // notice I'm not passing urlString as an array entry, since Chrome Application Shortcuts don't like that
    ],
  }),
}

module.exports = {
  // ...
  handlers: [
    {
      match: finicky.matchHostnames(["meet.google.com"]),
      ...googleMeetApp,
    },
  ],
};

This worked perfectly for opening Google Meet links in the newly made Google Meet app!

With this solution, I think this issue can be closed.

@johnste
Copy link
Owner

johnste commented Jan 31, 2021

Great to hear! I'm closing this issue, and I added a link to it in the wiki in case it might be useful for someone else.

@johnste johnste closed this as completed Jan 31, 2021
@schiegl
Copy link

schiegl commented Jul 26, 2021

The solution that @skoshy suggested does not work for app shortcuts created with Brave. The correct app opens, but only for the url the app shortcut was created for, not the custom url that was passed in urlString. Can anyone suggest a fix?

@skoshy
Copy link
Contributor Author

skoshy commented Jul 26, 2021

Hi @schiegl, I actually switched to using Brave (beta) too and I can confirm it does work with Brave. Here's what my config file looks like:

const workBrowser = {
  name: "com.brave.browser.beta",
  profile: "Profile 1"
};

const googleMeetApp = {
  browser: ({ urlString }) => ({
    ...workBrowser,
    args: [
      '--app-id=dbpkegghbgplfeaapbejbnfpbgnbjedf', // substitute with your app's app ID
      `--app-launch-url-for-shortcuts-menu-item=${ urlString }`,
    ],
  }),
};

module.exports = {
  defaultBrowser: "com.brave.browser.beta",
  handlers: [
    {
      match: finicky.matchHostnames(["meet.google.com"]),
      ...googleMeetApp,
    },
    {
      // Open any link clicked in Slack in my work browser
      match: ({ opener }) =>
        opener.bundleId === "com.tinyspeck.slackmacgap",
      browser: workBrowser
    },
  ]
}

This config works great for me for Google Meet; we have a pinned Meet link to a specific meeting in our Slack group, and clicking it opens that exact meeting in the Google Meet Brave app. Other Google Meet links open appropriately as well.

@schiegl
Copy link

schiegl commented Jul 26, 2021

What a coincidence that you switched to Brave @skoshy! Using "Profile 1" seems to work for Google Meet, but not for Jira. Jira opens in a new tab instead of the app shortcut window (which also opens but remains blank). Also, the profile the shortcut was created in is not named "Profile 1". Not sure why "Profile 1" works?

Lastly, for some reason opening links through finicky takes much longer than opening shortcut apps with the system launcher. Instead of ~1s, it takes 5s. This is not due to page loading, as opening the webpage in a tab also just takes ~1s. Does this also happen to you?

@skoshy
Copy link
Contributor Author

skoshy commented Jul 26, 2021

Also, the profile the shortcut was created in is not named "Profile 1". Not sure why "Profile 1" works?

So the profile doesn't refer to the profile name, it refers to the profile folder. For me, my work profile in Brave is named Work, but the folder is actually Profile 1.

You can find all the profile directories in ~/Library/Application Support/BraveSoftware/Brave-Browser-Beta (or Brave-Browser).

The default profile is just called Default. There's also the Guest Profile. Any other profiles you make are numbered (Profile 1, Profile 2, etc).

...but not for Jira. Jira opens in a new tab instead of the app shortcut window (which also opens but remains blank)

Hmm, only advice for this is to check if the right profile directory is being used, and the correct app-id. I haven't tried this with JIRA, so can't offer any more advice than that :/

Lastly, for some reason opening links through finicky takes much longer than opening shortcut apps with the system launcher. Instead of ~1s, it takes 5s. This is not due to page loading, as opening the webpage in a tab also just takes ~1s. Does this also happen to you?

For me, it adds maybe 1s delay, definitely not 5s though. That's an inherent problem with Finicky though I believe.

@schiegl
Copy link

schiegl commented Jul 27, 2021

Hmm, only advice for this is to check if the right profile directory is being used, and the correct app-id. I haven't tried this with JIRA, so can't offer any more advice than that :/

The app-id is correct as the correct app shortcut opens. It is however blank. Given that the other apps work, maybe I matched the url wrong.

For me, it adds maybe 1s delay, definitely not 5s though. That's an inherent problem with Finicky though I believe.

That is unfortunate.

@bigethan
Copy link

bigethan commented Aug 20, 2021

A short note, in chrome (with multiple profiles), specifying the profile caused this not to work (it'd open a blank chrome tab). Either commenting out that line( // profile: ...) or setting it to Default made it work

@pauloermoraes
Copy link

Hello guys, if the shortcut app is already open, it opens another instance of the shortcut app for you too?
How can I open the URL on the same instance?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants