johnste / finicky

A macOS app for customizing which browser to start
MIT License
3.76k stars 138 forks source link

Profile switching in Chrome not working #187

Open advicepyro opened 3 years ago

advicepyro commented 3 years ago

Describe the bug Prior to today, my Finicky setup consisted of Firefox Beta as my default browser, and internal company links (amongst others) going to Firefox Dev Edition. I experimented with switching everything to Chrome Dev and using profiles.

The default profile associated to my personal Gmail is in ~/Library/Application Support/Google/Chrome Dev/Default, and the profile associated to work in ~/Library/Application Support/Google/Chrome Dev/Profile 1.

It seems like the profile selection isn't working. Chrome continues to use whichever profile was last active in opening any new links. My example is to open links in Slack - internal links should have opened in Profile 1, whereas random links should open in Default.

Your configuration

module.exports = {
    defaultBrowser: {
      name: "Google Chrome Dev",
      profile: "Default"
    },
    handlers: [
        {
            // All work related domains:
            match: finicky.matchHostnames( ... ),
            browser: {
              name: "Google Chrome Dev",
              profile: "Profile 1"
            }
        }
    ]
}

Using latest finicky 3.4.0, Chrome version 91.0.4449.6, macOS 11.2.3

To Reproduce Steps to reproduce the behavior:

  1. Open Chrome
  2. Within Chrome, switch to work profile, then switch back to personal profile
  3. In Slack, open an internal company link that matches the above regex in the config
  4. Link opens in the personal profile instead of work profile
bhedavivek commented 3 years ago

~Ran into the same issue with newer versions of Google Chrome. I think we should move away from using the open command and switch to executing Apple Scripts. Verified if we directly reference the Chrome app and use the profile args open links with a specific profile still works.~

UPDATE: Google Chrome working fine. Had a bug in my config.

johnste commented 3 years ago

If someone wants to try I'm all for it. I have very little time to work on Finicky right now and the next couple of months probably, which is why I haven't been very active.

curtisolson commented 3 years ago

I'm having the same behavior. I use 4 profile. 1 personal and 3 work projects. I cannot get profile to work and I've triple verified the config file matched my chrome profile folder names. I'm new to Finicky. Tried to get log messages, but I cannot see anything in the console after opening a new link.

bhedavivek commented 3 years ago

I'm having the same behavior. I use 4 profile. 1 personal and 3 work projects. I cannot get profile to work and I've triple verified the config file matched my chrome profile folder names. I'm new to Finicky. Tried to get log messages, but I cannot see anything in the console after opening a new link.

You can add a finicky.log() in your config. Example here - https://github.com/johnste/finicky/issues/177#issuecomment-791730222

I would make sure finicky is your default browser, and relevant urls are logging your custom log message for a profile when you test using console.

Working fine for me on latest Chrome.

curtisolson commented 3 years ago

To try identify where the code stopped working, I tried earlier releases on Finicky. I first went back to 3.1 and it actually did do the profile swapping.

So I walked backwards from the latest release hoping I'd find the release that broke profile switching. I walked all the way back to 3.1, but then profile switching is no longer working for me. I'm positive it was working before, but nothing I try gets it back. Here's part of my simple config to test the links.

{ match: "github.com/1", browser: "Google Chrome", profile: "Default Profile" }, { match: "github.com/3", browser: "Google Chrome", profile: "Profile 3" }, { match: "github.com/4", browser: "Google Chrome", profile: "Profile 4" }, { match: "github.com/7", browser: "Google Chrome", profile: "Profile 7" },

bhedavivek commented 3 years ago

Ah, I think I see your issue. When specifying which profile to target you need to pass a JSON object for browser. The profile property is defined on this browser object (see: link).

you might want to set your handlers something like. Tried a similar config on my setup and can confirm works with latest Chrome.

[
  {
    match: "github.com/1*",
    browser: {
      name: "Google Chrome",
      profile: "Default"
    }
  },
  {
    match: "github.com/2*",
    browser: {
      name: "Google Chrome",
      profile: "Profile 1"
    }
  },
  ...
]
mitsumaui commented 1 year ago

Wanted to leave a comment here that I was struggling with Finicky loading different Chrome profiles - It kept just "creating" a new profile when a link opened via Chrome.

Turns out it was down to Chrome profile corruption. I deleted the ~/Library/Application\ Support/Google/Chrome directory and restarted Chrome - setup new profiles and all worked fine after that.

pwl0lwp commented 10 months ago

More feedback on this issue: Finicky and/or Chrome doesn't seem to recognise "Profile 1" as being a valid profile. Setting Profile to "Default" resulted in Finicky opening the "Profile 1" profile:

const personal = {
  name: "Google Chrome",
  profile: "Default",
};

const work = {
  name: "Google Chrome",
  profile: "Profile 2",
};

module.exports = {
  defaultBrowser:  personal,
  handlers: [

                {
                match: finicky.matchDomains([/mywork\.(|net|com)/]),
                browser: work
                },

        ],
};
Geczy commented 3 months ago

use this to get your profile names to chrome labels. then you can update your config appropriately

jq -r '.profile.info_cache | to_entries[] | "\(.key): \(.value.name)"' ~/Library/Application\ Support/Google/Chrome/"Local State"