Create URL Shortcuts to Websites on Ubuntu

13 Mar 2024, Bangkok

Sometimes, it’s handy to store a shortcut to a URL on the desktop.

Yesterday, I was hunting for grid paper and dotted paper on the internet to print out in order to tutor a nephew on negative numbers. The PrintablePaper website provided these and much more e.g. polar coordinates graphs, budget forms, calendars, etc.

I dutifully downloaded the ones I needed and saved them to the ~/ref/P/paper folder for future use. It would also be nice to be able to store a shortcut to the URL in the same folder for quick reference in the future.

Turns out, there is a way to do so. Just create a file named PrintablePaper.desktop with the following contents

[Desktop Entry]
Encoding=UTF-8
Type=Link
URL=https://www.printablepaper.net/
Icon=text-html
Name[en_US]=PrintablePaper

And it creates a file PrintablePaper without the “.desktop” extension.

ubuntu-desktop-shortcut

That’s fine except the icon for the shortcut looks decidedly unimpressive. Would have been better if it sported a logo of Firefox, my preferred browser, or a generic internet icon.

Given that there is a line Icon=text-html in the file, there must be a way to alter that somehow to give us a more reasonable icon. Poking around, the phrase text-html is a mime type that’s defined in /etc/mime.types and the icons are all stored in /usr/share/icons. Going through both files to find an icon is an exercise in frustration.

Setting the line to Icon=application-x-executable:

Icon=application-x-executable

To Icon=network:

Icon=network

Or to Icon=application-zip:

Icon=application-zip

Sigh - surely, there must be a better way! And there is - rather than using the stock icons, you can download an icon, put it somewhere and just use it.

[Desktop Entry]
Encoding=UTF-8
Type=Link
URL=https://www.printablepaper.net/
Icon=/home/hoekit/data/images/icons/firefox_logo.svg
Name[en_US]=PrintablePaper

The entry looks more respectable now with an icon courtesy of Alpár-Etele Méder:

ubuntu-desktop-firefox-logo

So imagine this: sometime in the future, whenever I need to print out a few pages of grid paper, just go to ~/ref/P/paper and print them, or if fancy strikes, double-click on PrintablePaper and explore what else there is available.

To be reminded contextually is a rather useful hack.

Written on March 13, 2024