Run a New Firefox Window with a Temporary Profile and Add it to the Ubuntu Menu

On Ubuntu, right-clicking on the Chromium browser icon you are shown 3 options:

  1. Open a New Window
  2. Open a New Window in incognito mode
  3. Open a New Window with a temporary profile
Contextual menu for the Chromium Browser on Ubuntu 16.04 with Unity

The Firefox browser just offers two options:

  1. Open a New Window
  2. Open a New Private Window
Contextual menu for the Firefox Browser on Ubuntu 16.04 with Unity

Here’s how you can add a script to get a new Firefox window with a temporary profile and add it to the actions to the Firefox contextual menu in the Ubuntu Unity menu.

The following script launches a new Firefox window with a temporary profile. The profile is created in a temporary directory that is removed when the script exits, using an exit trap. I also use the enhanced bash strict mode.

You can save this script as /usr/local/bin/firefox-temp-profileand make it executable with:

 $ sudo chmod a+x /usr/local/bin/firefox-temp-profile

Now you can run the command firefox-temp-profile and you will get a new window with a temporary profile.

To add an action to the contextual menu1:

  1. copy the firefox.desktop launcher from /usr/share/applications/ to ~/.local/share/applications/:

    $ cp /usr/share/applications/firefox.desktop ~/.local/share/applications/firefox.desktop
  2. Edit the new file:
    • Add the new action new-tempprofile-window to the Actions entry:
      Actions=new-window;new-private-window;new-tempprofile-window;
    • Add at the end of the file:
      [Desktop Action temporary-profile-window]

      Name=Open a New Window With a Temporary
      Exec=firefox-temp-profile
  3. Remove the old icon from the Unity Launcher by right-clicking it and choosing Unlock from Launcher
  4. Re-add the new icon by searching for Firefox in the Activities menu and dragging the Firefox icon to the Launcher

The new contextual menu has the action Open a New Window With a Temporary Profile:

Contextual menu for Firefox with the new action

A new window with a clean profile in Firefox – at least for version 76.0.1 (64-bit) – looks like this:

A Firefox window with a clean profile

  1. I am mostly following this AskUbuntu answer.