Introduction
I am working on a robot project with my brother. We share data (datasheets, pictures…) in a folder synchronized on dropbox.
He only uses Windows and I am mainly using Linux (debian based distros with GNOME Desktop Environment to be precise).
He tends to use Windows URL files to save web shortcut in a sharable way. But those files are not openable by default in Linux.
I want to open those .url
files with a simple double click.
Here is a way to automatically open Microsoft Windows URL shortcut file in Linux default browser.
MS Windows URL shortcut
A url file has the .url
extension and look like this
[InternetShortcut]
URL=https://www.example.com/
Creating the right application
In order to automatically open .url
files we need to create an “application” in GNOME.
This will be a bash script and and .desktop
file.
This will create an “open with” entry in the selection menu.
create executable
Create the bash script in /usr/bin/mswin-urlfile
and paste this content
#!/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
Then enable execution permission with
sudo chmod +x /usr/bin/mswin-urlfile
create application entry
To create an application entry in GNOME, we need to create a .dekstop
file.
create /usr/share/application/winurl.desktop
and paste this content
[Desktop Entry]
Type=Application
Name=WinURL
GenericName=WebBrowser
Icon=application-x-mswinurl
Comment="open msurl file in default browser"
Categories=Network;Utility;Viewer;WebBrowser
Keywords=web;url;windows;microsoft;win;ms;
NoDisplay=false
Exec=/usr/bin/mswin-urlfile %u
MimeType=application/x-mswinurl
select our new “application” to open URL files
- Find a
.url
file with the file explorer; - right click on it and select “open with”;
- scroll down the list and select “WinURL”;
- enable “Always use for this file type” at the bottom;
- finally click on “open”.
Tadam! You can now open all .url
files in your default browser by double clicking on it.
Sources
Comments
To give feedback, send an email to percevalsa [at] outlook dot com.