Desktop icons should be simple, but they’re not on Ubuntu 18.04 LTS and newer versions like Ubuntu 19.10. Follow these simple steps to get desktop shortcuts for your favorite applications just like you would on other operating systems and other Linux desktops.
Yes, it should be easier
Putting shortcuts on the desktop is one of the things Windows users do without even thinking about it. It’s unfortunate, but a newbie to Linux can find this simple task a frustrating task. It’s the kind of things that make them think that with Linux it’s going to be a long hard work getting anywhere.
Even people who have been using Linux for a while and are pretty knowledgeable can find this topic a lot harder than it should be. In fact, it’s not difficult, but it’s definitely counter-intuitive.
Install GNOME Tweaks
By default, you cannot copy files or icons to the Ubuntu GNOME shell desktop. To make this happen, you’ll need to use GNOME Tweaks to change a setting. Use this command to install it.
sudo apt-get install gnome-tweaks
After installation, press the “Super” key (between the Ctrl and Alt keys in the lower left corner of most keyboards) and enter “tweaks”. The tweaks icon is displayed. Click on it to launch Tweaks.
This is the icon in Ubuntu 18.04. The icon looks different in Ubuntu 19.10. Once Tweaks has started, click on “Desktop” in the left pane. Click the Show Icons slider to allow desktop icons. You can choose whether shortcuts to your home directory, the recycle bin, network servers and mounted volumes should be displayed on the desktop.
Note that the desktop icon settings in Ubuntu 19.10 are under the extension settings, so click on the “Extensions” entry in the left pane.
Create a desktop shortcut
To demonstrate this process, we’ll create a desktop shortcut for LibreOffice Writer. Now that we have enabled the ability to have icons on the desktop, all we have to do is drag something onto the desktop and we have a shortcut. But what do we have to draw?
It is a so-called .desktop file for an application. These are text files that describe certain attributes of the application. Among other things, they tell the operating system where the binary executable file is located in the file system. When you double-click the shortcut, Linux uses this information to locate and start the application binary. We just need to find the correct .desktop file.
Applications that are deployed as part of a distribution’s standard packages or installed from repositories have their .desktop files installed in:
Other applications installed locally with system-wide access – meaning they are available to all users – usually have their .desktop files installed in:
Applications that have been installed so that they can only be accessed by a single user will have their .desktop files installed in that user’s home directory:
LibreOffice is available to all users, so let’s start Files and navigate to the
/usr/share/applications Directory. You need to navigate to the appropriate directory for the application you are looking for.
Launch Files and click Other Locations in the left pane. Then navigate to Computer> usr> Share> Applications.
Scroll through the icons until you see the LibreOffice Writer icon. In Ubuntu 19.10, the icons all look like gears, so you’ll need to double-check the name of the file to make sure you have the correct .desktop file.
To make sure you have found the .desktop file of the application you are looking for, right-click the icon and select Properties. You should see a line telling you that this is a desktop configuration file. Close the properties dialog.
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 would normally move the item that was moved, in this case it is copied.
You now have an icon on the desktop, but it doesn’t look like it should. What’s happening?
While it doesn’t look what you’d expect, it’s a working shortcut. Double click on it to launch the application and you will be greeted with a warning dialog.
Click the Trust & Start button and two things will happen.
The icon changes its appearance and text label to what you would expect, and LibreOffice Writer starts.
You now have a LibreOffice Writer icon on the desktop that can be used as a shortcut to start the application. The Untrusted Application 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. Programs written in-house or applications you may have downloaded Github, to the example, are often not supplied with a .desktop file.
This is not a problem; we can easily create our own. All it is is a text file that lists the relevant details.
How to install software using Git on Linux
Create a .desktop file
On this test computer we have a program that does not have a .desktop file.
The first thing you need to do is verify that the application is running. If it doesn’t, you won’t get it working with a .desktop file either. But you can spend a lot of time going around in circles wondering why your .desktop file isn’t working. So, for the sake of thoroughness, make sure that the application starts and runs properly when started manually.
A .desktop file is a text file with settings in it. That alone is not enough to display an icon. We need to use an icon that came with the application. We can see that there is an icon called “ip_gc_icon.png” in the application directory and we are using it.
We can also see that the binary is called
gc . We need this information shortly.
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:
This identifies Linux what you will click when you double click on it.
All other entries in the .desktop file consist of labels and values connected by an equal sign
=. Make sure you don’t have any spaces immediately before or after the equal sign.
The next four lines describe the application.
Version=1.0 Name[en_US]=Geocoder GenericName[en_US]=Interesting Point Geocoder Comment[en_US]=Interesting Point Geocoder is a tool to create CSV files of geolocational data
- The entry “Version” is the version number from the program.
- The entry “Name” is the name of the application. Notice that we’ve added a locale ID, [en_US]what US English means. You could leave it out. If you were to create a multilingual .desktop file, these types of identifiers would be required for each different language section. You won’t make a difference here, but it’s a good habit to get into.
- The entry “GenericName” is used to contain a generic description of the application. This could be used to store descriptions like “video editor”, “web browser”, or “word processor”. This application doesn’t fall into any specific category so we’re just giving it a longer version of the application name.
- The “Comment” entry can contain any descriptive text.
The next three lines give Linux information so that it knows where the binary executable is and what icon to use for the shortcut.
Exec=/home/dave/geocoder/gc Path=/home/dave/geocoder/ Icon=/home/dave/geocoder/ip_gc_icon.png
- The entry “Exec” is the path to the executable binary file. In our example, This is that
- The entry “Path” is the path to the working directory of the application.
- The “Icon” entry is the path to the icon file that you want to use for the desktop link.
The last three lines are additional information on the application.
Terminal=false Type=Application Categories=Application
- The entry “Terminal” 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 from an application, link, or directory. Of course we would like our entry to be “Application”.
- The “Categories” entry can be used by Linux or GNOME to group similar or related applications into menus. We’re just entering a generic “application”.
A complete list of possible .desktop file entries and their values can be found in the .desktop file specification.
Here is our full .desktop file:
Save the file in the application directory and ensure that it has a .desktop extension. Our example The file is called “Geocoder.desktop”.
How to graphically edit text files on Linux with gedit
Copy the .desktop file to the desktop
To copy the .desktop file to the desktop, right click on it and select “Copy” from the context menu. Right-click on the desktop and select “Paste” from the context menu.
If you double-click the icon on the desktop, you will see the same warning dialog as before. Click the Trust and Start button.
The desktop icon takes on its real appearance and the application starts.
Copy the .desktop file to the application folder
Since this program is used by a single user, we will copy the .desktop file to his / her local application directory. Use this command in the program directory:
cp ./Geocoder.desktop ~/.local/share/applications
If you place the .desktop file in the local application directory, the application is integrated with the GNOME search function. Press the “Super” key (between the Ctrl and Alt keys in the lower left corner of most keyboards) and enter the first part of the name of your application. Its icon will appear in the search results.
- Left click on it to launch the application.
- Right click on it and choose “Add to Favorites” to add it to your Ubuntu dock.
Ready to go
So there you have it. A little lengthy, but simple enough.
And definitely counterintuitive.