‘xdg-open’ does not open the default browser

To set a default browser, make sure that a .desktop file exists for your preferred browser. I’ll be setting Mozilla Iceweasel for this example:

ls /usr/share/applications/iceweasel.desktop

Output:

iceweasel.desktop

Assured you have the file, run:

xdg-settings set default-web-browser iceweasel.desktop

# Test that it works
xdg-open "http://example.com"

If you don’t have a .desktop file:

I use the program surf, which doesn’t have a .desktop file. To set this as your web browser, first create the file ~/.local/share/applications/surf.desktop with this following content:

[Desktop Entry]
Type=Application
Name=surf
Comment=Surf minimal web browser
Terminal=false
Exec=surf
Categories=Network;WebBrowser

While not all of this content is required, it helps categorize the file for any future use.

Set the default browser like normal:

xdg-settings set default-web-browser surf.desktop

And now you’re good to go!

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)