Monday, November 12, 2012

Setting up multiple Firefox profiles in Ubuntu 12.04 and Windows 7

Introduction

One of the more underrated features of the Firefox Web Browser is the ability to set up different user profiles.

This feature comes quite a bit in handy when you have different people using the same computer, but don't require the overhead of setting up separate user accounts for each individual using it.

Setting up separate profiles allows multiple people to have Firefox configured the way they like it: with different bookmarks, saved passwords,  personal history, and so on.

Plenty of people like to keep their browsers signed in to the services they like for convenience (not having to keep signing back in), but when multiple people share a computer, signing people in and out all the time can be a hassle. Enter Profiles, unique "Firefox's" (so to speak) for each person. On my system, I have three profiles: One of myself, one for my better half, and one for guests which uses Firefox In-Private mode so their personal passwords, etc., are not tracked. You could even have different profiles for work and personal use, if you choose.

Firefox profiles are very easy to set up and manage, in today's post, I'll show you how to set them up on both Ubuntu 12.04 and Windows 7.

Ubuntu 12.04

I'll start off with a few assumptions here: You already have one Firefox profile set up and one short cut in your Unity Launcher (or other launcher of your choice). This is how Ubuntu comes by default, so it's not too crazy to assume this. If for some reason this isn't the case, you can easily install Firefox with the Ubuntu Software Center. Also, we'll assume that your secondary profiles (for other users), will also be accessed from the Unity launcher.

Creating new profiles

Before adding the new Firefox sessions to the Ubuntu browser, we'll have to set them up in Firefox first. First, launch a Terminal. Then, from the command line, run:

firefox -no-remote -ProfileManager

Most likely, you already have one profile named something like "Default". Feel free to keep this named Default, or rename it to your own name. Just remember whatever name you give it.

To make a new profile, click the "Create Profile" button:



Firefox will give you some data about profiles (pretty much what I summed up above), and then you can click "Next" and enter a name for the new profile. You can also change the directory the profile is stored, although most likely the default will be sufficient.

Create as many profiles as you desire, remembering the name for each. When you are done, close the Profile Manager.

Setting up different launchers for each Profile

There are actually two different ways you could go about this. You could just keep using your single Firefox launcher, but have it ask on launch what profile to use. To do this, from the Profile Manager, simply uncheck "Don't ask on startup". This will allow you to pick which profile you want each time you start.

But personally, I prefer to have a separate Unity launcher for each profile. This allows each person to access their own profile with just a single click. This is pretty each to set up, but also requires some more Terminal to work. Basically, we're going to change the default launcher to open one profile (your own for instance), then make new launchers for the other profiles.

From Terminal, navigate to:

/usr/share/applications

Here, you'll find all (or at least most) of the launchers used by Ubuntu and Unity, there should be one for Firefox called "firefox.desktop". Open it in your favourite text editor (with root access).

There is a lot of stuff in here, but you only have to make a very minor change or two. Look in the file for the lines beginning with "Exec=". This is the command which is executed when the launcher is run. For example:

Exec=firefox %u

To make it launch a specific profile, use the -P flag:


Exec=firefox -no-remote -P Jason %u

The "-no-remote" flag causes Firefox to launch it's own process rather than trying to connect to an existing process. This way, we can have different Firefox sessions with each profile open simultaneously. Make the change to all Exec lines in the file and save.

Pro-Tip: You might notice upon saving that the Firefox icon disappears from the Unity launcher. If it does, no sweat. Just open /usr/share/applications in Nautilus, find the "firefox.desktop" file, and drag it over to the Unity launcher. Keep Nautilus open since you'll need to do this for subsequent launchers.



To make a new launcher for another profile, just copy the firefox.desktop file to a different name, e.g. "profile2_firefox.desktop". Open it in a text editor and make the same changes to the "Exec" line. But don't save yet.

In order for Unity to isolate this launcher from the original, it's important that you also change the "Name=" line. For example, change:

Name=Firefox Web Browser

to something more personal like:

Name=Profile2_Firefox

Do this for all instances of "Name".

You can also change the icon easily too, so there aren't two Firefox icons in the Launcher. To do this, change the "Icon=" from:

Icon=firefox

To something else. One icon I like looks like a small picture of the planet:

Icon=/usr/share/icons/gnome/48x48/emblems/emblem-web.png

But feel free to poke around /usr/share/icons and find one you like better!

Finally, once you've saved the launcher, don't forget to to to /usr/share/applications on Nautilus and drag it over to the Unity launcher!

That's about it, just repeat the process for each profile you want. If you'd like a "Private" session to use (to avoid tracking passwords, etc), use the "-private" flag in your Exec line.

You can also keep using a "default" Firefox icon if you wish. This will cause the last profile to be launched which was launched with the ProfileManager. One might want to do this if you frequently launch links from other other applications (e.g. Thunderbird). In this case, just keep the default Firefox icon using the most frequently used profile (your own), but use alternate icons to launch other profiles.

Pro-Tip: I also set up a keyboard shortcut to launch the Guest Firefox session. To do this, just make a script (in the "Home", or "Home/Scripts" folder for example) with the following content:


firefox -P Guest -no-remote -private

Replace "Guest" with whatever you might have named the Guest profile. Save, then right click on the file and go to "Properties", then the "Permissions" tab. Check "Allow executing this file as a program":



Now, launch the HUD and type "keyboard". Open the Keyboard settings and go to "Shortcuts". Under "Custom Shortcuts" click the "+" button. Give it a name, and point the command to your script. Click Apply. To active the new short cut, click on where it says "Disabled", then hit the key combination you want to trigger it (for example CTRL-ALT-P). Now try hitting CTRL-ALT-P and you should see the private Guest profile launch.



Windows 7

The process in Windows 7 is quite similar, but seems to be less flexible then Ubuntu.

To open the ProfileManager in Windows 7, hit Win+R to open the Run menu. Then, type "firefox -no-remote -p" to open the Profile manager.

Create your Profiles exactly as described above.You can also un-check "Don't ask at start up" if you want to pick the profile to use every time.

Assuming to have your Firefox icon docked on the Start Bar (a.k.a. Task Bar), you can continue to just click on that icon, which will launch whatever the last profile started with the Profile Manager was. Unfortunately, I haven't figured out how to make the docked Firefox icon always start a specific profile (but if you know, please mention it in the comments).

You also also create shortcuts to launch other Firefox profiles. To do this, from the Desktop, Right-click and say "New->Shortcut". Use "Browse" to select the Firefox executable (you'll likely find it near C:\Program Files (x86)\Mozilla Firefox").

But before saving it, make the following change:

Before: "C:\Program Files (x86)\Mozilla Firefox\firefox.exe" -no-remote -P "Profile1"

Where "Profile1" is the name of an alternate profile.

You can make as many of these on the Desktop as you want, and even drag them into the Start Menu. Unfortunately, the Start Bar only seems to allow us to have a single icon, which launches whatever was last launched with the ProfileManager. I'm not sure why this is, but it's a limitation we'll have to live with for now (again, if you have any advice, please let us know).


Hopefully this is a feature of Firefox you'll find useful, I certainly do. Just one of the things that makes Firefox such a great browser!

One final tip: You can protect your saved passwords in Firefox by using a Master Password. This can come in handy in case your computer is ever stolen or its security otherwise compromised.





1 comment:

  1. Thanks Jay
    This article is very clear and functional.
    Finally I can share my Thunderbird on Windows and Ubuntu. (I'm sorry my English writing).

    ReplyDelete