How can I create a shortcut for URL in my desktop? I want to use them in Firefox or Chrome.
If a copy and paste didn't work.
What script I have to use?
How can I create a shortcut for URL in my desktop? I want to use them in Firefox or Chrome.
If a copy and paste didn't work.
What script I have to use?
In Ubuntu an URL shortcut is stored in a .desktop file as follow (for example):
You can drag links from Firefox or Chrome and drop them on the Desktop or any other folder where you have permissions to save files.
Note: Link will appear on your Desktop or your file explorer (i.e. caja) under the name in the line
Name=…
, not by its actual filename. And without any….desktop
extension.This solution is multi-platform also:
Create a new simple text file with an .html extension and whatever name you want.
Edit the file with the program you want and add this content:
Save the file.
I needed something like this, but Gnome (now?) requires
*.desktop
files to be in specific locations, so using those directly wouldn't solve my problem, as I wanted web-links for reference mostly in project folders. And they wouldn't be cross-platform compatible either.Eventually I turned to Microsoft's
.url
files, which are easily constructed and look like this:(I read that the trailing line break is important, and probably should be
\r\n
for Windows compatibility)And created a .desktop specification to handle them:
Put that into a file in
~/.local/share/applications/<whatever>.desktop
. In my case Gnome immediately bound*.url
files to them.This requires
xdg-utils
package (forxdg-open
, it's likely there if you have a desktop-environment) and python 3.I really really didn't want to use python, but doing unchecked parsing on something like this didn't suit me. The largest parts of the python script are to avoid infinite loops among other dangers -- in case someone gets funny ideas and puts a file name in a
.url
file. It ensures that a scheme is present and is one ofhttp(s)
,ftp
,ssh
. I guess that list can be easily extended, but I actually don't know which schemes Windows supports.Add this to your
~/.bashrc
:-To create a shortcut, do as follows:-
The first argument is the name you want to be displayed in nautilus.
The second argument is the url.
The third argument is the actual name of the file which will be appended by .Desktop extension.
Note that this will create a file with name RGBD-Dataset-Link.Desktop but will be displayed as RGB-Dataset in nautilus.
Try this. Install Gnome Panel, just press Ctrl+Alt+T on your keyboard to open Terminal. When it opens, run the command(s) below:
Once installed type this:
(location of shortcut). In the example below, I will create a shortcut for Ubuntu.com and place it inside the Documents folder. Once I hit Enter a window will open with the properties. See images below.
Once done, just click on them newly created shortcut.
Additionally, like all solutions that involve a command line, one can do it with a the mouse in three steps in a Chromium like browser :
Afterward, one
.desktop
file shall be added to the desktop of the creator.You can just copy the following into a text file and save it with a
.desktop
file extension in the desktop folderThis works for me on Ubuntu 20.04. It uses the terminal for launching a URL. you can change
google-chrome
tofirefox
if you like that browser more.I tried different things but this was the one that helped me out.
Edit: using
Type=Link
is superior (see accepted answer).As some others suggested, a desktop file launching the browser with the url as an argument works really well. I would like to add that you can pass it to
xdg-open
(installed by default) instead offirefox
orgoogle-chrome
, to open up the default browser instead of having the browser hardcoded into the file.Something like:
Don't forget to include the protocol (
https://
in this case), orxdg-open
will be looking for a directory instead.Then, make sure to right click the file on the desktop and select "Allow Launching" (Ubuntu 20.04) to turn it into a desktop icon.
Wow this was sticky! So many answers with such complexity, here is a clean solution -
Solution
QuickCut - Add a context menu to quickly save shortcut files (url, desktop, webloc)
Procedure
Done! ??
I had the same problem with creation shortcuts from chromium, and I found how to fix it for myself: for example -
I just add "chromium" to exec, and now it's work for me, and the final code looks like -