Friday, November 6, 2009

How to run multiple instances of Firefox

So this issue is widely talked about on the internet with a lot of lame solutions involving creating multiple profiles. I don't want to create multiple profiles. I want to open new instances of Firefox at will. Not new windows, entirely new instances, and I want to use the same profile for all of them.

My situation is I installed Ubuntu 9.10 with Gnome. I don't particularly like Gnome, but I'll suffer it for a while, I suppose. In Gnome, you can add nifty application launchers so a single click will start the app. For Firefox, if you make the application launcher and click it once, Firefox opens. If you click it again, you get this dreaded message:

"Firefox is already running, but is not responding. To open a new window, you must first close the existing Firefox process, or restart your system."

Big fat lie, that is. If I open a terminal window, and type "firefox", I get a new instance. I can do this over and over and create as many new instances as I want. But I can't do it from the launcher, which is annoying.

So here is how to do it:

  1. Create this script:

    #!/bin/bash
    nohup /usr/bin/firefox > /dev/null 2>&1 &
    sleep 2

    The 'nohup' line starts Firefox as a separate instance, the 'sleep' line gives that instance enough time to get started before the terminal exits.
  2. Save it somewhere and make it executable. I put it in my ~/bin directory and named it "firefox".
  3. Create an app launcher by right clicking on your panel and picking "Add to panel" from the menu.
  4. From Accessories, add Terminal (yes, Terminal, not Firefox).
  5. Right click on the terminal icon, and choose "Properties".
  6. In the "command" box, it says "gnome-terminal". Add a space and type in "--execute /home/danson/bin/firefox" or whatever the path is for where you saved the script in step 2.
  7. Change the icon to the firefox icon.
Multiple Firefoxes!

No comments: