johnste / finicky

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

Support for Firefox profiles #90

Open llange opened 4 years ago

llange commented 4 years ago

I'd like to see some support for Firefox Profiles (ability to open some urls in one or another profile, having both instances open and directing urls to one instance or another). It will involve the use of some specific command line options (-P, --no-remote).

Use-case

My ideal use-case is the following:

Workaround

As there is currently no support for profiles in Finicky, I was using, until recently, the following workaround:

with: ./Contents/Info.plist being a copy of ~/Applications/Firefox.app/Contents/Info.plist with the following changes:

and ./Contents/MacOS/firefox-<customer1> being:

#!/bin/sh
exec $HOME/Applications/Firefox.app/Contents/MacOS/firefox-bin -P "<Customer1Profile>" --no-remote "$@"

This workaround used to work fine and allowed me to use, in Finicky, the bundle Id to refer to the browser: I could use this to refer to the default browser:

    defaultBrowser: {
        name: 'org.mozilla.firefox',
        appType: 'bundleId',
        openInBackground: false
    },

or this to refer to the browser for customer1:

browser: {
    name: 'org.mozilla.firefox-<customer1>',
    appType: 'bundleId',
    openInBackground: false
}

Unfortunately, a few Finicky versions ago, it stopped working (for non default browsers). (I did not notice at which version the change occurred)

I did not dig it too much, but in the logs I have the following error message (Note: Using Catalina 10.15.1):

2019-12-09 13:47:05.802952+0100 0xa9f584   Default     0x0                  45389  0    open: (LaunchServices) [com.apple.launchservices:open] Opening URL <private> with application <private>
2019-12-09 13:47:05.809145+0100 0xa9f584   Default     0x0                  45389  0    open: (LaunchServices) [com.apple.launchservices:open] _LSLaunch('<private>')
2019-12-09 13:47:05.811925+0100 0xa9f584   Default     0x0                  45389  0    open: (LaunchServices) [com.apple.processmanager:front-35286506] LAUNCHING:0x0-0x888888 Firefox-<Customer1> foreground=1 bringForward=1 seed=6891 userActivityCount=0
2019-12-09 13:47:05.813343+0100 0xa9f584   Error       0x0                  45389  0    open: (LaunchServices) [com.apple.launchservices:cas] LaunchedApplication: failed with error -13052 (null){ "ApplicationType"="Foreground", "BundleIdentifierLowerCase"="org.mozilla.firefox-<customer1>", "CFBundleExecutablePath"="/Users/llange/Applications/Firefox-<Customer1>.app/Contents/MacOS/firefox-<customer1>", "CFBundleExecutablePathDeviceID"=16777223, "CFBundleExecutablePathINode"=1440551, "CFBundleIdentifier"="org.mozilla.firefox-<customer1>", "CFBundleName"="Firefox-<customer1>", "CFBundlePackageType"="APPL", "CFBundleSignature"="MOZB", "LSASN"=ASN:0x0-0x888888:, "LSBundlePath"="/Users/llange/Applications/Firefox-<Customer1>.app", "LSBundlePathDeviceID"=16777223, "LSBundlePathINode"=1440545, "LSDisplayName"="Firefox-<Customer1>", "LSExecutableFormat"="LSExecutable#!Format", "LSLaunchDLabel"="org.mozilla.firefox-<customer1>.8412", "LSLaunchedByLaunchServices"=true, "LSLaunchedInQuarantine"=true, "LSLaunchedWithLaunchD"=true, "LSLaunchEventRecordTime"=384911881317822, "LSLaunchTime"=now-ish 2019/12/09 13:47:05, "LSWantsToComeForwardAtRegistrationTimeKey"=true, "pid"=62000 }
2019-12-09 13:47:05.813887+0100 0xa9f584   Default     0x0                  45389  0    open: (LaunchServices) [com.apple.launchservices:open] OSStatus _LSLaunch(LSContext *, FSNode *, LSLaunchFlags, void *, CFArrayRef, const AppleEvent *, const AEDescList *, CFArrayRef, CFDictionaryRef, LSBundleID, const audit_token_t *, const _LSOpen2Options *, ProcessSerialNumber *, Boolean *, NSError **): launching '<private>' result=0

May be I'm able to fix it, but it still is a workaround, and in this time of quarantined, notarized applications, there is no guarantee that my workaround setup is viable long term.

Thus I believe proper support for browser command lines (like in #89) or profiles (browser-specific, see also #40) is cleaner for this kind of use-case.

Thanks !

ldub commented 4 years ago

@llange, I suspect that this stopped working due to updating to Catalina and not due to a Finicky version update.

llange commented 4 years ago

Hi @ldub , I'm pretty sure you're right, I didn't make the link but I had a (forced) upgrade to Catalina which do coincide with the breakage.

I do hope to find a way to make my setup work again...

ldub commented 4 years ago

As I mentioned here https://github.com/johnste/finicky/issues/40#issuecomment-581168657 , other apps have this problem too. One was able to find a workaround, but overall it seems like a macOS bug that we need to report to Apple, or potentially a sandboxing "feature" that they have added to Catalina.

p-prakash commented 4 years ago

Hi @llange , did you find any workaround. I'm stuck with the same problem. Another issue I have is that I have two Firefox instance open with two different profiles and even without finicky the link is trying to open two different windows again withe default profile as reported in Bugzilla.

llange commented 4 years ago

Hi @p-prakash , unfortunately, no, I do not have a workaround at the moment, and thus I'm not using finicky any more as a consequence... which is sad as I like the tool. And this is an area where I'm not able to help further - apart from testing a new release and see if it works.

jdnicholas commented 4 years ago

Hi @p-prakash , @llange I don't know if I'm missing something with what you're intending to do, but I've managed to get Finicky to work with opening different Firefox Profiles by creating a new Firefox application in my applications folder called "WorkFirefox". (I did this by just renaming the Firefox.app in my Applications folder, and dragging a new version from the Firefox.dmg installer to create the two apps. The profiles are still all stored in the normal location: /Users/YourMacUsername/Library/Application Support/Firefox/Profiles/ )

I then assign my Work profile as the default in WorkFirefox.app, and assign my Personal profile as default in normal "Firefox.app" and use the recently added Finicky functionality for opening by application path e.g.

{match: ({ keys }) => keys.shift, browser: "/Applications/WorkFirefox.app"},
{match: ({ keys }) => keys.function, browser: "/Applications/Firefox.app"},

to open WorkFirefox with the shift key, and Firefox with the function key for example.

I don't know if this is would provide what you're looking for as a workaround?

anmull commented 4 years ago

Hi Prakash P , unfortunately, no, I do not have a workaround at the moment, and thus I'm not using finicky any more as a consequence... which is sad as I like the tool. And this is an area where I'm not able to help further - apart from testing a new release and see if it works.

@llange if you change the browser in finicky to the absolute path of the app instead of the bundle it will work.

browser: "/Applications/Firefox-<customer1>.app"

I have the same setup of multiple Firefox "app"s running an exec script and the above works for me for each profile.

notDavid commented 4 years ago

Just an FYI: the "opening different Firefox Profiles by creating a new Firefox application" workaround does not work properly for me in the latest Big Sur public beta.

For example, when Firefox is already opened with "profile 2" active, and I launch an url assigned to this "profile 2", nothing happens. I do however see a second Firefox dock icon bouncing next to the Trash that doesn't open.

When i close Firefox, launching an url assigned to this "profile 2" does work though... 🤷🏼‍♂️

-- Finicky v3.1.1 (246)

alex-popov-tech commented 3 years ago

thanks @llange ! worked for me. but still would like to see it built-in ( since people do that anyway ). perf is approx same as brave/chrome

kiblik commented 1 year ago

This is solution which works for me (one Firefox, multiple profiles)

    browser: ({ urlString }) => ({
      name: "Firefox",
      args: ["-P", "nameOfWorkProfile", `${urlString}`],
    }),
sourcecodemage commented 7 months ago

This is solution which works for me (one Firefox, multiple profiles)

    browser: ({ urlString }) => ({
      name: "Firefox",
      args: ["-P", "nameOfWorkProfile", `${urlString}`],
    }),

Where would these line inside of .finicky.js?

I currently have the example file , and would like to add your solution to it

module.exports = {
    defaultBrowser: "Google Chrome",
    rewrite: [
      {
        // Redirect all urls to use https
        match: ({ url }) => url.protocol === "http",
        url: { protocol: "https" }
      }
    ],
    handlers: [
      {
        // Open apple.com and example.com urls in Safari
        match: finicky.matchHostnames(["apple.com", "example.com"]),
        browser: "Safari"
      },
      {
        // Open any url that includes the string "workplace" in Firefox
        match: /workplace/,
        browser: "Firefox"
      },
      {
        // Open google.com and *.google.com urls in Google Chrome
        match: [
          "google.com/*", // match google.com urls
          "*.google.com/*", // match google.com subdomains
        ],
        browser: "Google Chrome"
      }
    ]
  };

Thanks!