Ubuntu – xdg-open only opens a new tab in a new Chromium window despite passing it a URL

chromiumxdg-open

When I am using xdg-open to open a link in Chromium, it just results in a new Chromium window with only the new tab page, with nothing else.

For example, xdg-open 'https://askubuntu.com' will just open a new Chromium window and won't open up AskUbuntu.

It just seems that the URL isn't being passed to Chromium, as invoking Chromium directly does work and opens the desired page: chromium-browser 'https://askubuntu.com' works.

Obviously, Chromium is the default browser.

Where could the problem be, and how can I fix that? It is especially annoying when some programs use xdg-open to open a link and you can't go to the page you want, or even see what was opened.

Best Answer

The issue is indeed that xdg-open does not pass the requested URL to Chromium, so instead of running chromium-browser url-here, it is executing chromium-browser which just opens a new window.

After searching on the Internet, I found out that xdg-open uses some "config" files located in /usr/share/applications.

/usr/share/applications/chromium-browser.desktop seemed to be correct, as it is configured to pass the URL to Chromium correctly:

$ grep Exec /usr/share/applications/chromium-browser.desktop
Exec=chromium-browser %U
...

So what was wrong? It turns out that there's another location which xdg-open uses and that has priority over /usr/share/applications.

$ grep Exec ~/.local/share/applications/chromium-browser.desktop
Exec=/usr/lib/chromium-browser/chromium-browser --use-system-title-bar --ppapi-flash-path=/usr/lib/pepflashplugin-installer/libpepflashplayer.so --ppapi-flash-version=14.0.0.125

I have no idea as to why there's another chromium-browser.desktop, but note that this Exec line does not pass the URL; it is missing the %U. So I simply appended %U to this line. This instantly fixed all issues with xdg-open and Chromium.