Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Set Firefox profile directly within the application bundle Web Browsers
I share a computer with my wife (using one account), and we both use Firefox and many of the same services (Gmail, Facebook, etc.). As such, it can be quite a hassle to keep track of who logged in last and who added what bookmarks.

Fortunately, Firefox provides the capability to have separate profiles for just such a situation. Unfortunately, it is not very simple to set up an easy and consistent way to launch those profiles. So, here are some of the options I tried before arriving at what I think is a pretty good solution.

Option 1: Use the profile manager. In this mode, the profile manager will pop up every time Firefox is launched and you can choose your profile. This is nice and all, but what if my wife wants to launch Firefox while I already have it open? If she clicks the Firefox icon in the Dock, it just brings the app to the front and does not give the profile manager dialog.

Option 2: Create a script that will call the profile directly. This option is close to a good solution, since I can have separate scripts for each profile, solving the second instance issue of Option 1. However, this option creates extra Firefox icons in the Dock, and it can be confusing to figure out which instance is which.

Option 3: Create an entire copy of Firefox.app, and edit the contents of each copy to launch a specific profile. Say, for example, that the profile name is Bob. First I would create a copy of Firefox.app and rename it Firefox-Bob.app. Next, I run a fancy script (see below) that scans the /Applications directory and modifies Firefox-Bob.app to launch the Bob profile directly.

This means there is only one Dock icon for the instance of Firefox-Bob, and clicking that icon brings Firefox-Bob to the front. The one drawback to this method is that each time Firefox needs to auto update, it will blow away the profile modification. This is not really a big deal, however, since all you need to do is re-run the script to reset things.

Here's the script (also available via DropBox):
#!/bin/bash

# Go into Applications folder
cd /Applications > /dev/null

# Get a list of all files of form Firefox-Username.app
ls -1 | grep Firefox- | \
while read line
do

    # Go into the app package contents
    pushd $line/Contents/MacOS > /dev/null

    # Check to see if this app has already been converted.
    # If the file is binary then it has NOT ben converted yet.
    isBinary=`file firefox-bin | grep binary`

    if [ -n "$isBinary" ] # Will be true if isBinary is NOT empty (i.e. it IS binary)
    then

        # Get the username from the app name.
        user=`echo $line | sed "s/Firefox-\(.*\)\.app/\1/"`

        # Print some feedback
        echo Converting $line for user $user

        # Move the binary file to a new spot
        mv firefox-bin firefox-bin1

        # Write the following lines into a file with the same name as the previous
        # binary file, firefox-bin
        echo '#!/bin/bash' >> firefox-bin
        echo '/Applications/'$line'/Contents/MacOS/firefox-bin1 -P '$user' &' >> firefox-bin
        echo sleep 3 >> firefox-bin
        echo osascript -e "'tell application \"Firefox-$user\" to activate'" >> firefox-bin

        # Make the newly written file executable.
        chmod a+x firefox-bin
    else

        # Just like the feedback says, don't do anything since this file is
        # not a binary file.
        echo $line has already been converted.  No changes made.
    fi

    # Go back out of the package so we're ready to process the next one (if any)
    popd > /dev/null

done

# This part is a bit of bash foo.  The command above is actually a single command with
# a three part pipe (ls | grep | while read line).  The PIPESTATUS is indexed by
# the location in the pipe sequence, 0, 1, 2, ...  So, the risk of failure here
# is that the grep will not find a matching sequence.  Thus the error we're after
# is index 1.
err=${PIPESTATUS[1]}
if [ $err -ne 0 ]
then
    # Say something meaningful to STDERR so it will show up
    # even if it is being called from applescript.
    echo "Could not find any files to convert in the" >&2
    echo "Applications folder!" >&2
    echo >&2
    echo "Files must match the form Firefox-Profilename.app" >&2
    echo "where Profilename is the actual profile name to use." >&2
fi
exit $err
You can probably figure out what is going on by looking at the contents of the script, but here is what I'm doing to the application's contents:
  1. Rename /Applications » Firefox-Bob.app » Contents » MacOS » firefox-bin to firefox-bin1.
  2. Create a shell script called firefox-bin that calls firefox-bin1 with the -p Bob argument.
  3. Make the shell script executable.
  4. Add a touch of AppleScript to bring the instance of Firefox-Bob to the front after it launches.
[robg adds: I haven't tested this one. Separate accounts for each user would seem like a good alternative solution, but perhaps they have good reasons for using but one account.]
    •    
  • Currently 2.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (15 votes cast)
 
[7,673 views]  

Set Firefox profile directly within the application bundle | 17 comments | Create New Account
Click here to return to the 'Set Firefox profile directly within the application bundle' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Set Firefox profile directly within the application bundle
Authored by: stephenr on Nov 17, '09 07:44:53AM

MultiFirefox is a much simpler method to achieve this. http://davemartorana.com/multifirefox/



[ Reply to This | # ]
Set Firefox profile directly within the application bundle
Authored by: phlops on Nov 17, '09 10:08:06AM

I recently did this myself using a different and simpler method. The reason why I went this way and didn't use MultiFirefox is that I want it to be simple. By editing the .app bundles for the older versions of Firefox I have installed I can simply click the icon in my Dock (or use Launchbar or what have you) and that particular version of Firefox launches with its own profile in use so that I can use as many as I want concurrently.

The instructions are at http://flickr.com/dokas/4016880175/ which I cobbled together from http://nxsy.org/firefox-30b4-and-multiple-firefox-versions-on-os-x.

Basically you create a new file in the Contents/MacOS/ directory of the app bundle, I named mine launcher.sh and you edit this script to be its contents:

#!/bin/sh

MYDIR=`dirname "$0"`
cd "${MYDIR}"
./firefox-bin -P YOURPROFILENAMEHERE "$@"

Then you edit your Info.plist to use "launcher.sh" as the binary location (CFBundleExecutable is the plist key name). Then, for me on 10.5 at least, I had to rebuild my launch services database using my preferred tool, Cocktail. Repeat these steps per Firefox version with a unique profile and boom: as many Firefox versions as you want, all runnable at once.

---
/phil



[ Reply to This | # ]
Set Firefox profile directly within the application bundle
Authored by: richwiss on Nov 17, '09 10:09:42AM

Even simpler, you can do what my wife and I do: I use Firefox and she uses Safari!



[ Reply to This | # ]
Set Firefox profile directly within the application bundle
Authored by: Unsoluble on Nov 17, '09 10:19:45AM

Wow, those are great technical solutions, and it's always good to see alternative ideas, but... Have you thought about multiple user accounts, with Fast User Switching? That would appear, to me, to be the much superior method -- and waaay simpler. Why not?



[ Reply to This | # ]
This is exactly what separate user accounts is for!
Authored by: rgray on Nov 17, '09 11:57:56AM

+1 for user accounts as a much cleaner, simpler solution which can be set up by anyone. Use the Unix underbelly the way it was meant to be used!



[ Reply to This | # ]
Set Firefox profile directly within the application bundle
Authored by: tedw on Nov 17, '09 01:06:10PM

Amen. I always wonder why people share the same account. There's no value to it (fast user switching takes seconds, with no hassles), and there's so much confusion over who did what when two people are sharing. not to mention hassles with apps like Mail.app and iTunes...

one user, one account; that makes everything so much easier.



[ Reply to This | # ]
Set Firefox profile directly within the application bundle
Authored by: osxpounder on Nov 18, '09 02:06:20PM

Depending on a person's needs, there is plenty of value in using the same account.

Mainly, one never needs to even think about file permissions.

Simply having shared files in one place is good. We do it in real life, and sometimes, maybe even most of the time, we'd like to be able to do that with files on the family computer.



[ Reply to This | # ]
Set Firefox profile directly within the application bundle
Authored by: tedw on Nov 18, '09 02:37:20PM

even the most tight-knit families keep personal items in separate drawers, and keep their clothes in separate spaces in the closet. it's natural to have those kinds of minor divisions to keep things simple. On a computer, the easiest and best way to do that is with separate user accounts. There's nothing saying that you can't share each other's passwords, and no reason why you can't set up things that are best held in common (like music and videos) so that they are shared between accounts, of course. using a combined account, though, means you have to do tricky things (like this firefox hack) to keep some separation between what the two of you are doing, and runs the risk that your spouse will do something (say, tidy up a few folders, or add an application) that will accidentally delete, mangle, or otherwise muck up files that you need.

I mean, I get it: there's an intimacy issue and a laziness issue, both of which work against separate user accounts. but it's not like you're *actually* saving yourself any effort by using a single account, and you're opening the door to a whole unfortunate can of worms by doing so.

Even if you choose not to, please do tell your kids to do it. I've seen too many college students post requests for help because they let their dorm-mates use their account, and the dorm-mates borked the system on them.



[ Reply to This | # ]
Set Firefox profile directly within the application bundle
Authored by: Dr. T on Nov 17, '09 03:03:51PM

I tried this, but since my wife and I need to access most of the same stuff (e-mail, personal finance, address books, photos, home movies, etc.), I would have to move nearly everything into the Shared Folder (which was accessible by our kids over our network). It was too much trouble just to have different settings on a couple of apps and different bookmarks in our browser.

We chose the Firefox (me) and Safari (wife) solution.



[ Reply to This | # ]
Set Firefox profile directly within the application bundle
Authored by: leamanc on Nov 18, '09 06:02:02PM
I still vote for Fast User Switching in your case. Use the /Users/Shared/ directory, or install something like Dropbox to access your shared files (i.e., you both create Dropbox accounts and set up shared folders, or log in to the same Dropbox account from both OS X accounts).

[ Reply to This | # ]
Set Firefox profile directly within the application bundle
Authored by: everkleer80 on Nov 19, '09 08:25:59AM

Dropbox just to share files on the same machine?? Keep in mind that you will have 2 copies of each file that way (yes they're kept in sync but it does use twice the disc space... I suppose that's not too big a concern assuming your sharing small files - if not then you're out of luck anyway as the free Dropbox accounts only currently allow 2GB.) You also have to upload then download everything (unless Dropbox is smart enough to handle it when both users are logged in - I've never tested it but I hear it somehow supports LAN sync now if the users are on the same network, so maybe it also handles if they're on the same computer.)



[ Reply to This | # ]
Set Firefox profile directly within the application bundle
Authored by: tedw on Nov 19, '09 09:50:58AM
who needs dropbox? just go to the Sharing panel in System Preferences, click file sharing on, and add the folders you care about up so that everyone has access to them. no moving files, no duplicates, no fuss, no muss.

I get that you don't want to do this, and that's your choice. You can do things any way you like on your computer. But let's not suggest that everyone should adopt the funky workarounds that you find comfortable when there is a simple and easy-to-use mechanism to handle these issue built into the system.

[ Reply to This | # ]

Set Firefox profile directly within the application bundle
Authored by: phlops on Nov 19, '09 08:14:28AM

One huge reason for having multiple versions of Firefox that can be opened simultaneously *in one single account* is the simplicity it affords web developers who need to debug, verify, and debug in older versions of Firefox.

This is compounded by the fact that popular development extensions like Firebug don't support all versions of Firefox in the same version of the plugin. By being able to launch Firefox 2.0 with its own unique profile I can have it use the last version of Firebug that supports it and similarly so for 1.0, 1.5, 3.0, 3.5, etc.

---
/phil



[ Reply to This | # ]
Try this = very easy and works great!
Authored by: slb on Nov 17, '09 12:24:02PM

Close the Firefox application completely and make sure that it is not running in the background.

Assuming the program is installed in the "Applications" folder, launch Terminal ("Applications -> Utilities -> Terminal") and enter the command in Terminal:

/Applications/Firefox.app/Contents/MacOS/firefox-bin -profilemanager

Next time you launch FF, it shows the profile manager!

Scott



[ Reply to This | # ]
Set Firefox profile directly within the application bundle
Authored by: tdyas on Nov 17, '09 01:03:09PM

On Snow Leopard, "dock tile plugins" allow an application to offer menu choices on the dock menu before an application is started. See https://bugzilla.mozilla.org/show_bug.cgi?id=524338 for more information. (That patch allows you to start Firefox in safe mode. Modifying it to allow access to other profiles is left as an exercise for the reader.) Of course, that support is not currently in Firefox so it really only helps people who can compile their own Firefox.



[ Reply to This | # ]
Set Firefox profile directly within the application bundle
Authored by: tyrone_slothrop on Nov 19, '09 08:07:56AM
I found a slightly more elegant solution. You can write an applescript:
do shell script "/Applications/Firefox.app/Contents/MacOS/firefox-bin -P default -no-remote &> /dev/null &""
which will open an instance of Firefox with whichever profile you specify in place of default. Now save the applescript as an application and name it something like Bob Firefox and you're ready to go, even if you update Firefox. Just create a second script and application for your wife's profile.

[ Reply to This | # ]
Set Firefox profile directly within the application bundle
Authored by: slvrstn on Nov 21, '09 08:00:05AM
I just use
open -na firefox
from the terminal.

This opens a new copy of the named application. I use it with adium as well. I also use profiles in both apps, but want to separate business and personal usage and sometimes need to have two different active profiles in firefox.

[ Reply to This | # ]