codeblog code is freedom — patching my itch

November 21, 2008

directing firefox url opening

Filed under: Blogging,Debian,Ubuntu,Web — kees @ 5:53 pm

A while ago, I found a way to open multiple firefox instances so I could have multiple cookie/password repositories. One issue that plagued me was that when launching URLs from other applications (e.g. liferea, gnome-terminal, etc), the URL would open in the longest running firefox, so if I opened my Browsing instance first, then my Authenticated instance, URLs would open in the Browsing instance. That’s what I wanted.

However, if I had to restart my Browsing instance (like, say, when flash was crashing), URLs would start opening in the Authenticated instance, which I didn’t want. So, I changed the Gnome preferences to run this script when launching a browser:

#!/bin/sh
firefox -p Browsing -remote 'openURL('"$@"')'

Ta-da, URLs are always directed to the “Browsing” instance, regardless of when it was started.

© 2008, Kees Cook. This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 License.
CC BY-SA 4.0

2 Comments

  1. Great hint! However, what I run into is that if you have multiple FF windows open, it opens links in the *newest* window. I want it to open links in the FF window in the same virtual desktop as the app with the clicked link (follow that?).

    I can’t imagine there’s a simple way of accomplishing this as it would require FF to know what virtual desktop it was being asked to open a link from. Its such a tiny annoyance I’m not too worried about it and should probably just use multiple profiles to accomplish a sensible solution.

    Comment by Michael Schurter — November 21, 2008 @ 11:44 pm

  2. hi, this is great. at least it sounds like what I was looking for for quite a while.

    Could you explain where and how you call the script?

    In Intrepid System>Preferences>Prefered Applications I can choose different options for firefox.

    I selected custom and pointed to a script containing the code you suggest… sadly it does not work… any suggestions?

    Comment by seb — November 26, 2008 @ 11:09 pm

Powered by WordPress