Launch different browsers, based on the URL
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.
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:
#!/bin/bash URL=$1 GOOGLE="^https?://.+\.google\..+/" GSEARCH="^https?://.+\.google\..+/search" if [[ $URL =~ $GOOGLE ]] && [[ ! $URL =~ $GSEARCH ]]; then chromium-browser $URL else firefox $URL fi
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] Version=1.0 Name=Autobrowser, detect by URL GenericName=Web Browser Exec=/path/to/the/browser-script.sh %u Terminal=false X-MultipleArgs=false Type=Application Icon=firefox Categories=GNOME;GTK;Network;WebBrowser; MimeType=text/html;text/xml;application/xhtml+xml;application/xml;application/rss+xml;application/rdf+xml;image/gif;image/jpeg;image/png;x-scheme-handler/http;x-scheme-handler/https;x-scheme-handler/ftp;x-scheme-handler/chrome;video/webm;application/x-xpinstall;
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.
Kan du lide hvad du lige har læst? Så tryk på Flattr-knappen til venstre og red verden.