Launch different browsers, based on the URL

9. maj 2014 af Mikkel Munch Mortensen

In my onging struggle as a tin foil hat to not be tracked by Evil Corp™ and it's government associates, I've started blocking cookies from anything Google in my primary browser.

I still use Google search once in while. It works perfectly fine without cookies (and it may even help you pop your filter bubble).

But I ran into some problems with all the Google Apps – Calendar, Docs, etc. – which I use daily at work. I started using these in a separate browser, Chromium, but whenever I clicked a link – e.g. in an e-mail – pointing to a shared document or a calendar event, it opened in my primary browser, and I had to copy/paste the link to Chromium. That was kinda annoying.

Today I created a small bash script that, based on the URL, launches the right browser:




if [[ $URL =~ $GOOGLE ]] && [[ ! $URL =~ $GSEARCH ]]; then
    chromium-browser $URL
    firefox $URL

Only thing I needed was to register this script as the default browser in Ubuntu. After searching the interwebz for a while, I found a solution:

You need to create a custom-browser.desktop file in ~/.local/share/applications/ that resembles this:

[Desktop Entry]
Name=Autobrowser, detect by URL
GenericName=Web Browser
Exec=/path/to/the/ %u

Then make sure the new application is registered by running update-desktop-database ~/.local/share/applications and voilà: It's possible to select this as the default browser in the Default Applications settings. Screenshot of the default apps selection in Ubuntu

Skriv kommentar

  • Brug Textile hvis du vil lave funky ting i din kommentar.