You can make your Linux file manager open .URL file in your default browser. This is particularly useful for people who share files between Windows and *nix machines. To do this create a script file let's call it mswin-urlfile
(or what ever you like) in /usr/local/bin
(or your preferred folder). Change permission: chmod +x /usr/local/bin/mswin-urlfile
#!/usr/bin/bash
if [ "$1" == "" ] || [ "$1" == "--help" ] ; then
echo "$(basename "$0") URLFILE - opens a .url file in the default browser"
else
sed 's/^BASEURL=/URL=/' "$1" | grep -m 1 '^URL=' | sed 's/^URL=//' | sed 's/\r//' | xargs xdg-open
fi
To test use it manually from a shell prompt using:
mswin-urlfile test.url
Next you will need to configure file manager to call mswin-urlfile
when opening a .URL file type. This works across all *nix and shells allowing you to open your .URL files from within your file manager. Exactly how to do this depends on the file manager you use. Lookup "file association" for the specific file manager you use.
For example Nautilus file manager is mentioned at 369967 and create a mimetype for the .url extension
Open Applications > System Tools > File Types Editor, and click the New button. Enter the following information in the corresponding tabs:
► General:
Category: Text and source code
Name: x-url
Description: Microsoft Internet Explorer Shortcut
You can choose an icon for the .url file-type via the browse button […] – if you don’t have any, there are some at the bottom of this post that you can save to a folder like /home/yourusername/Settings/Icons.
► Filenames:
Filename pattern: *.url
► File contents:
When you click +Add, you’ll see more than one data entry field, but all you need to worry about is the Value: one.
Value: [InternetShortcut]
Now your system knows what .url files are, but it still doesn’t know what to do with them. You now have to associate the .url extension with the executable script fx-url, so right-click any .url file and go to Properties > Open With. Click the Add button, and at the bottom of the “Add Application“ window you’ll see the “Use a custom command“ option; click this, then either browse to /user/bin and select the symlink you created, or enter /usr/bin/Web Shortcut Browser (or the appropriate name if you changed it). Click the Add button to save your changes (but leave the “Properties“ window open as you’ll need it in the next step).
Now you need to make the associated action the default option for double-clicking, otherwise you’ll have to right-click .url files and choose the required option from the context menu. To make opening in Firefox the default action, in the Open With tab of the “Properties“ window, click the dot to the left of the entry you just added (eg: “Web Shortcut Browser“), then click Close.
open any Nautilus (file manager) window and go to Edit > Preferences > Behaviour. In the “Executable Text Files“ section, make sure that “View executable text files when they are opened“ is selected. Click Close, and it is done (you may need to log out or reboot for the changes to take effect). Now when you right-click any .url file, you should see “Open with Web Shortcut Browser“ as the top entry of the context menu, and it will be the default action for double-clicks.
I use a different file manager so I have not tested the above Nautilus instructions.
I prefer to keep using URL files as I use a mixed environment Android + app to open or create URL files; Linux + script (above) to open URL files; Windows (built in URL file support). Alternatively, you could convert every system to just use bookmark files and sync them, but builtin browser syncing has messed up my bookmarks more than once. If you use different browsers (eg Chrome, Firefox, Brave) on different system syncing is not simple.