Using Firefox profiles in Ubuntu Unity

As described in another post, I use Firefox profiles to keep various activities separate – different banks, different AWS accounts and so on. It’s easy enough to use them from the command line, but it is much nicer to just click on an icon and have the right profile start up. Here is how to do that for one window manager, Ubuntu’s Unity.

Note that this is for Ubuntu 16.04 LTS. The instructions will probably work fine for later versions, but YMMV as they say.

The steps

What we are going to do is:

  • create a personal desktop file for Firefox (“desktop files” are what the Launcher and the Desktop use to start programs via icons)
  • add Firefox to the Launcher. The Launcher is the vertical bar of icons at the far left of a standard Ubuntu Unity screen.
  • create a new Firefox profile
  • add an entry to the desktop file

You will be then able to start Firefox with the desired profile by selecting it via the icon in the Launcher.

1: Create a personal desktop file

You can do this in Nautilus, or the file manager of your choice, or on the command line in a  terminal window. Copy this file:

/usr/share/applications/firefox.desktop

into this directory:

~/.local/share/applications

Any file in the latter directory will take precedence over the default version in /usr/share/applications. You could always edit the one in /usr/share/applications, but then all users on the system would get the modified version, so it is better to take a copy and modify the copy. Also, that way if you screw it up, you can just take another copy and start again 🙂

2: Add Firefox to the Launcher

You can skip this step if you already have Firefox in your Launcher. Otherwise:

  • Open up the dashboard by clicking the topmost con on the Launcher

 

  • Type “Firefox” into the search bar, and you should see the Firefox icon

  • Drag the Firefox icon onto the Launcher and drop it

There should now be a Firefox icon in your Launcher.

If you middle-click the Firefox icon in the Launcher, you should get a new Firefox window.

If you right-click the icon, you should see a context menu drop down. It will look something like this (if you have Firefox open,there will be a “Quit” option too):

3: Create a new Firefox profile

To do this, check out this blog post. Come back here when you are done.

You will need the name of your new profile. For the purposes of this blog post we will pretend that your profile’s name is “My Profile”, but you should substitute your profile’s actual name wherever needed.

4: Add an entry to the desktop file.

Remember that you will be editing your local copy of the default desktop file.

Use your favourite text editor – such as gedit – to open and edit this file:

~/.local/share/applications/firefox.desktop

Search for a line that begins with “Actions=“.

Choose a “tag” for your new profile. To avoid difficulty, I suggest that the tag be the profile name in lower case and with all spaces and special characters removed. For example, “My Profile” would become “myprofile”.

Append or insert your tag into the “Actions” line. The default “Actions” line is something like this:

Actions=new-window;new-private-window;

so you would change it to this:

Actions=new-window;new-private-window;myprofile;

Make sure the tags stay separated by semi-colons (“;”).

The entries in the context menu will be presented in the same order as the entries in the “Actions” line – so put your tag in the in the actions list at the same position as you would like your entry to appear in the menu. Only the default entry, “Unlock from Launcher” and “Quit” have fixed positions.

Add a blank line, then these lines, to the end of the file:

[Desktop Action myprofile]
Name=My Custom Profile
Exec=firefox -P "My Profile"

Notice that you use the tag inside the square brackets, but you use the profile name inside the “Exec=” line. If your profile name has any spaces in it, make sure you enclose the name in double quotes.

The “Name=” value is what will appear in the menu. It can be anything you like, though the menu will not display leading or trailing spaces.

Finally, save the file and close the editor.

5: Start Firefox with your new profile – from the Launcher

Right click on the Firefox icon in the Launcher. You should see that the menu now has a new entry representing your profile:

Click on the new entry, and Firefox will start with your new profile.

By the way…

The above technique can be used for more than just profiles. For example, you can have entries that take you straight to a particular URL to save you clicking on a bookmark. Check out the --new-window and --new-tab Firefox options for this.

You don’t even have to start Firefox! You can start any program you like via the “Exec=” line, but it might get a bit confusing if you start Chrome from the Firefox icon…

Leave a Reply

Your email address will not be published. Required fields are marked *