Enforce which version of program to use?

I have a somewhat peculiar problem – I occasionally run two different versions of Firefox on my Mac, simultaneously; one version is old, and the other very old. I do this sometimes for web development purposes because there are useful webdev plugins that Mozilla keeps destroying with their frequently changing browser architecture.

Each separate version of Firefox that I use connects to a different Firefox profile (so each version’s settings / system-library files are different) and has a different Finder name, even a different icon. So they’re essentially two different programs that happen to be running at the same time; this works well for most of my purposes. Except…

Firefox sometimes needs to interact with other programs and processes, including perhaps Finder, AppleScript, and MacOS itself. For some reason those other programs can’t seem to distinguish between my two Firefox versions; links or commands will always be routed to the last version of Firefox that I launched, no matter what I specify. If I write an AppleScript and tell it to switch to or activate my “Firefox_ESR”, but I happened to launch “Firefox_WebDev” more recently, the command will be sent to Firefox_WebDev despite my AppleScript explicitly specifying “Firefox_ESR”.

Why does this happen? How does the Mac internally distinguish one program from another, beyond just its Finder name, and is this something I can adjust in Terminal or elsewhere? Is there any solution?

Thanks for any insight into this rather obscure/strange question!

The name that the OS uses to identify a process is stored in the app’s Info.plist, inside the app package. I believe it’s the CFBundleName string (but I’m not 100% certain, and too lazy to double-check developer docs right now). This is the name that you see in Activity Monitor when an app’s running. Only the file system cares about the app’s Finder name.

I don’t know offhand if editing this string locally might affect any internal workings of a particular app—hypothetically, the code could reference the bundle name in a way that breaks things if you change it—but if you do it on a copy of the app, you can always trash the copy if it doesn’t work. If you open the app package in the Finder (right-click, “Show Package Contents”), Info.plist is inside the Contents folder and can be edited in any text editor or plist editor.

The least ambiguous way to reference running processes is by PID, of course, but since those change every time an app’s launched, referencing them in an AppleScript is a lot more complicated, and not worth the effort if changing CFBundleName works.

1 Like

Yes, as @Quantumpanda says, canging the bundle name (app ID like org.mozilla.firefox) to something else (like org.mozilla.firefox-esr) should work. I use this to run Aperture on Monterey (courtesy of Retroactive). But… two caveats I’m aware of:

  • You will likely need to re-sign the app for it to run on newer OSes or Apple Silicon (or both). This can be done as an ad-hoc signing from the command line. I can’t remember the command and am on my phone, but a search should turn up the necessary incantation.

  • You will either need to rename any preference files to the new bundle ID or set them up again. I don’t know what, if anything, Firefox stores in its MacOS preference file, but it might be how it locates the profile and settings to use.

Once you’ve done this, you should be able to use the new bundle ID in any AppleScript or shell script (again, look up the scripting dictionary and man page for the open command to see how to specify an app by bundle ID).

I think you can provide additional parameters when accessing an application class (tell application ...), to specify a version.

See: AppleScript Class Reference: application

The examples presented in the above mention a few ways referencing an app:

  • By name: tell application "TextEdit"
  • By app signature: tell application id "ttxt"
  • By bundle ID: tell application id "com.apple.TextEdit"
  • By app path: tell application "/Applications/TextEdit.app"

If you know the location of the version of Firefox you want to launch, try the last option - specifying the path to it.

Looking over the other options to the application class, you may also be able to specify the version, although I don’t see an example showing its usage. I suspect this may work (e.g. to launch Firefox version 97.0.1 only):

tell application id "org.mozilla.firefox" version "97.0.1"

In this case, I’m specifying the app by ID (since you’ve got two different apps with different filenames), and a version number. Assuming this works, it should do what you want, but keep in mind that it will probably fail if the specified version (in this case 97.0.1) isn’t running. So if you upgrade it, you’ll need to update the script as well.

4 Likes