How to Create Desktop Shortcuts on Ubuntu

The GNOME Shell Desktop of Ubuntu 18.04.

Desktop icons must be simple, but they are not simple in Ubuntu 18.04 LTS and newer versions such as Ubuntu 19.10. Follow these easy steps to get shortcuts to desktops for your favorite applications, such as other operating systems and other Linux desktops.

Yes, it should be easier

Removing shortcuts on the desktop is one of the things that Windows users do without thinking too much about it. It's unfortunate, but a newcomer to Linux can find it frustrating to do this simple task. It's the kind of thing that makes them feel like it's going to be a long and hard job to get things done with Linux.

Even people who have been using Linux for a long time and who know it well can find this subject much more ardent than it should be. In reality, it's not difficult, but it's really counterintuitive.

Installing GNOME Tweaks

By default, you can not copy files or icons to the Ubuntu GNOME Shell Desktop. To make this possible, you will need to use GNOME Tweaks to change a setting. Use this command to install it.

sudo apt-get install gnome-tweaks

sudo apt-get installs gnome-tweaks in a terminal window

Once the installation is complete, press the "Super" key (between the Ctrl and Alt keys at the bottom left of most keyboards) and type "tweaking". The Tweaks icon will appear. Click on it to launch Tweaks.

The Tweaks icon in Ubuntu 18.04

This is the icon in Ubuntu 18.04. The icon will be different in Ubuntu 19.10. Once Tweaks launched, click on "Desktop" in the left pane. Click the "Show Icons" slider to allow the desktop icons. You can choose whether you want to use shortcuts to your home directory, trash, network servers, and mounted volumes displayed on the desktop.

Desktop settings in the application window in Ubuntu 18.04

Note that in Ubuntu 19.10, the settings of the desktop icon are under the extensions settings, so click on the "Extensions" entry in the left pane.

Creating a shortcut on the desktop

To illustrate this process, we will create a shortcut on the desktop for LibreOffice writer. Now that we have enabled the possibility of having icons on the desktop, we just have to drag something on the desktop and we will have a shortcut. But what do we need to drag?

This is called a .desktop file of an application. These are text files describing certain attributes of the application. Among other things, they tell the operating system the location of the binary executable in the file system. When you double-click the shortcut, Linux uses this information to search for and launch the application's binary file. We just need to find the right .desktop file.

Application .desktop files that are provided with the default packages for a distribution or installed from repositories are installed in:

/ usr / local / share / applications

Other locally installed applications with system wide access, which means that they are available to all users, usually have their .desktop files installed in:

/ usr / local / share / applications

Applications installed so that they are accessible only to one user have their .desktop files installed in the home directory of this user:

~ / .local.share / applications

LibreOffice is available to all users. We will launch Files and navigate in the / usr / share / applications directory. You will need to access the appropriate directory for the application you are looking for.

Launch the files and click on "Other Locations" in the left pane. Then go to Computer> usr> share> applications.

Scroll through the icons until the LibreOffice Writer icon appears. In Ubuntu 19.10, the icons all look like gear wheels. You must therefore check the file name to make sure you have the correct .desktop file.

Files window displaying the LibreOffice Writer icon

To make sure that you have found the .desktop file of the application you are looking for, right-click on the icon and select Properties. You should see a line telling you that there is a desktop configuration file. Close the properties dialog.

LibreOffice Writer .desktop File Properties dialog box.

Left-click on the LibreOffice Writer icon, hold down the left mouse button and drag the icon to the desktop. Release the mouse button. Although this usually moves what was dragged, in this case, he copies it.

You now have an icon on the desktop, but it looks nothing like it should. What is going on?

Office icon immediately after being moved to the office

Although it's not what you expected, it's a functional shortcut. Double click on it to launch the application and a warning dialog will open.

Warning dialog on an unapproved launcher

Click on the "Trust and Throw" button, and two things will happen.

The icon will change appearance and the text label will look like what you expected, and LibreOffice Writer will be launched.

Using the shortcut on the LibreOffice Writer desktop.

You now have a LibreOffice Writer icon on the desktop that can be used as a shortcut to launch the application. The "Unapproved Applications Launcher" dialog box appears only the first time you use the shortcut.

What if the .desktop file is missing?

Sometimes applications do not provide a .desktop file. In-house programs or applications that you may have downloaded from GithubFor example, often do not come with a .desktop file.

This is not a problem; we can easily create ours. It is only a text file containing the appropriate details.

RELATED, RELATED, RELATED: How to install software with Git on Linux

Creating a .desktop file

On this test computer, we have a program that does not have a .desktop file.

The first thing to do is to check that the application is running. If it does not, you will not make it work with a .desktop file either. But you can spend a lot of time running around wondering why your .desktop file does not work. Therefore, for the sake of accuracy, make sure your applications are started and working properly when you start them manually.

A .desktop file is a text file with its parameters. This alone is not enough to display an icon. We must use an icon provided with the application. We can see that an icon called "ip_gc_icon.png" is in the directory of the application and we will use it.

We can also see that the binary file is calling gc. We will need this information shortly.

geocoder directory with visible icon

Open an editor. We will use gedit, but you can use the editor of your choice.

The first line of the .desktop file must be:

[Desktop Entry]

This identifies in Linux what you click when you double-click it.

All other entries in the .desktop file are composed of labels and values, joined by an equal sign =. Make sure you do not have any space directly before or after the tie.

The following four lines describe the application.

Version = 1.0
Last name[en_US]= Geocoder
Generic name[en_US]= Interesting point geocoder
Comment[en_US]= Interesting point Geocoder is a tool for creating CSV files of geolocated data.
The "Version" entry is the version number of the program.
The entry "Name" is the name of the application. Note that we have included a locale ID, [en_US], which means American English. You can give up. If you create a multilingual .desktop file, these types of identifiers are required for each language section. They will not make any difference here, but it's a good habit to take.
The "GenericName" entry is used to hold a generic description of the application. This could be used to contain descriptions such as "video editor", "web browser" or "word processor". This application does not fall into any particular category, so we will give it a longer version of the application name. .
The entry "Comment" may contain any descriptive text.

The following three lines provide information to Linux so that it knows where the binary executable is and what icon it should use for the shortcut.

Exec = / home / dave / geocoder / gc
Path = / home / dave / geocoder /
Icon = / home / dave / geocoder / ip_gc_icon.png
The "Exec" entry is the path to the binary executable. In our example, it is the gc executable.
The entry "Path" is the path of the application working directory.
The "Icon" entry is the path to the icon file that you want to use for the shortcut on the desktop.

The last three lines are additional data regarding the application.

Terminal = fake
Type = Application
Categories = Application
The "Terminal" input can be true or false. It indicates whether the application is running in a terminal or not. Our entry must be "wrong".
The "Type" entry can be an application, a link or a directory. Obviously, we want our input to be "Application".
The "Categories" entry can be used by Linux or GNOME to group similar or related applications into menus. We will simply enter a generic "Applications".

You will find a complete list of possible .desktop file entries and their values ​​in the Specifying the .desktop file.

Here is our complete .desktop file:

The finished .desktop file in the gedit editor

Save the file in the application directory, making sure that it has the ".desktop" extension. Our sample file is called "Geocoder.desktop".

RELATED, RELATED, RELATED: How to graphically edit text files in Linux with gedit

Copy the .desktop file to the desktop

To copy the .desktop file to the desktop, right-click it and select "Copy" from the pop-up menu. Right-click on the desktop and select "Paste" from the context menu.

When you double-click the icon on the desktop, the same warning dialog box will appear as before. Click on the "Trust and Launch" button.

Unapproved Launcher Warning Dialog

The desktop icon will take its true appearance and the application will be launched.

Application successfully launched from desktop shortcut

Copy the .desktop file to the Applications folder

As this program will be used by a single user, we will copy the .desktop file to its local applications directory. In the program directory, use this command:

cp ./Geocoder.desktop ~ / .local / share / applications

cp ./Geocoder.desktop ~ / .local / share / applications in a terminal window

Placing the .desktop file in the local applications directory integrates the application into the GNOME search function. Press the "Super" key (between the Ctrl and Alt keys at the bottom left of most keyboards) and type in the first part of your application name. Its icon will appear in the search results.

Application icon found by GNOME search

Click on it to launch the application.
Right click on it and select "Add to Favorites" to add it to your Ubuntu dock.

Ready for launch

So there you have it. A bit long, but simple enough.

And certainly counterintuitive.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.