I'm using Chrome as my default browser in Ubuntu 12.10. I need to use Firefox for business purposes (certain websites pertaining to my work only work with Firefox). Is there a way to force Ubuntu to use Firefox for certain types of URLs (maybe as defined by a regular expression) while maintaining Chrome as my default browser for all my other tasks? Perhaps as a shell script running in the background? I'd like this to work system-wide, covering links from Chrome itself as well as PDFs/ODTs, etc.
I have searched for solutions, but I couldn't find anything besides OpenWith, a Firefox extension which adds a button to open certain links in other browsers which would again require me to open Firefox beforehand, which does not help me at all.
Does anyone have any ideas? Something like Choosy for Linux?
Best Answer
The executable in Linux that opens a resource with your "favorite" program is called
xdg-open
. It is somewhat complicated, but you can add additional rules usingxdg-mime install
. However, I don't know if you can even do this for something like a specific URL.This becomes further complicated in that specific desktop environments use different executables and methods for opening their default programs. For instance KDE has
kde-open
, but not every KDE application seems to use this.Regardless, I got this partially working just using a shell script and a list of domains/URLs in a file. You can tweak it to your liking.
Note: You may need to repeat this process for other executables depending on your desktop environment. For example, Gnome has
gvfs-open
, KDE haskde-open
, and XFCE hasexo-open
. (Even then, it might not work for every application.)Note: The shell script is dependent on
pcregrep
being installed on your system.Find the
xdg-open
executableCreate a new directory in your home folder
Add the following to your
~/.bashrc
file~/.bashrc
Create the shell script in the newly created folder. (Be sure to edit the top four variables so they are correct for your system!)
~/.local/bin/xdg-open
Create the list of domains in your home folder
~/domains.txt
Log out and log back in to have the settings take effect