Equivalent of .URL file on Ubuntu

In Ubuntu an URL shortcut is stored in a .desktop file as follow (for example):

[Desktop Entry]
Encoding=UTF-8
Name=Link to Best Practices Software engineering
Type=Link
URL=http://abdennour-insat.blogspot.com/
Icon=text-html

If you still want to open your Windows URL files in Ubuntu, here is described how you can do it:

  • How to Open .url Internet Explorer Shortcuts in Ubuntu Using Firefox.

The Perl script given in that article appears to be broken, but the following code should do the same thing correctly:

#!/usr/bin/perl
# Script to make Microsoft Windows Internet Shortcuts (*.url) work on Linux.

my $browser = 'sensible-browser';  # use the system default browser

while (<>) {
    # match any line of the form "URL = something-without-spaces"
    if (/^\s*URL\s*=\s*(\S+)\s*$/) {
        exec $browser, $1;         # successful exec never returns
        die "$0: could not launch $browser: $!\n";
    }
}

In Unity we have .desktop files for defining items on the launcher, desktop, or other locations. To create these see the following question:

  • How can I create launchers on my desktop?

A link to an internet file may have an entry as simple as the following

[Desktop Entry]
Encoding=UTF-8
Name=Internet Link
Type=Link
URL=<url>
Icon=<icon to display>

You can create such a file with a text editor, or much easier by simply dragging and dropping a bookmark from your browser to the desktop.

However keep in mind that such a simple .desktop file will not automatically open the given URL in a browser if the target is e.g a text document, or image. To overcome this see the following question:

  • Desktop internet shortcut opens as text file

In case we do need to open .URL files more often (e.g. from a shared drive) we may also run a bash script similar to this to open them:

#! /bin/bash

# opens Windows URL file submitted as command line argument in browser

source $1
xdg-open $URL

The command not found error from this script can be ignored or sent to /dev/null. If we must then we could associate this script to a Mime type for the extension URL to double click open an URL file.