Desktop icons should be simple, but they’re not on Ubuntu 18.04 LTS and newer releases like Ubuntu 19.10. Follow these easy steps to get desktop shortcuts for your favorite applications, just like on other operating systems and other Linux desktops.
Yes, It Should Be Easier
Dropping shortcuts on the desktop is one of those things that Windows users do without overthinking about it. It’s unfortunate, but a newcomer to Linux can find doing that simple task a frustrating struggle. It’s the type of thing that gives them the impression that getting anywhere with Linux is going to be a long hard slog.
Even people who’ve used Linux for a little while and know their way around pretty well can find this topic much more of a struggle that it ought to be. In actual fact, it’s not difficult, but it is definitely counter-intuitive.
Installing GNOME Tweaks
By default, you can’t copy files or icons to Ubuntu’s GNOME Shell desktop. To make this possible you’ll need to use GNOME Tweaks to change a setting. Use this command to install it.
sudo apt-get install gnome-tweaks
When it has installed, press the “Super” key (between the Control and Alt keys on the bottom-left of most keyboards) and type “tweaks”. The Tweaks icon will appear. Click on that to launch Tweaks.
This is the icon in Ubuntu 18.04. The icon will look different in Ubuntu 19.10. When Tweaks has launched, click on on “Desktop” in the left-hand pane. Click the “Show icons” slider button to allow desktop icons. You can choose whether you wish to have shortcuts to your home directory, the trash can, network servers, and mounted volumes shown on the desktop.
Note that in Ubuntu 19.10, the desktop icon settings are under the Extensions settings, so click the “Extensions” entry in the left-hand pane.
Creating a Desktop Shortcut
To demonstrate this process, we’re going to create a desktop shortcut for LibreOffice writer. Now that we’ve turned on the ability to have icons on the desktop, we just need to drag something to the desktop, and we’ll have a shortcut. But what do we need to drag?
It’s something called an application’s .desktop file. These are text files that describe certain attributes about the application. Amongst other things, they tell the operating system where the binary executable resides in the file system. When you double-click the shortcut, Linux uses this information to find and launch the application’s binary file. We just need to find the right .desktop file.
Applications that are provided as part of a distribution’s default packages, or are installed from repositories, have their .desktop files installed into:
Other applications that have been locally installed with system-wide access—meaning they are available for all users—usually have their .desktop files installed into:
Applications that have been installed so that they are only accessible to a single user have their .desktop files installed into the home directory of that user:
LibreOffice is available for all users, so we’re going to launch Files and browse to the
/usr/share/applications directory. You’ll need to navigate to the appropriate directory for the application you’re looking for.
Launch Files, and click on “Other locations” in the left-hand 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 cogged wheels, so you’ll need to check the name of the file to make sure you have the correct .desktop file.
To make certain you’ve found the .desktop file of the application you’re looking for, right-click the icon and select properties. You should see a line telling you this is a desktop configuration file. Close the properties dialog.
Left-click on the LibreOffice Writer icon, hold the left mouse button down, and drag the icon to the desktop. Release the mouse button. Although this would usually move what was being dragged, in this case, it copies it.
You’ve now got an icon on the desktop, but it doesn’t look anything like it should. What’s going on?
Although it doesn’t look like you’d expect, it is a working shortcut. Double-click it to launch the application, and you’ll be greeted with a warning dialog.
Click the “Trust and launch” button, and two things will happen.
The icon will change its appearance and text label to look like you’d expect it to, and LibreOffice Writer will be launched.
You now have a LibreOffice Writer icon on the desktop that can be used as a shortcut to launch the application. You’ll only see the “Untrusted Application Launcher” dialog the first time you use the shortcut.
What if the .desktop File is Missing?
Sometimes applications do not provide a .desktop file. Programs that have been written in-house or applications you might have downloaded from Github, for example, often don’t come with a .desktop file.
That’s not a problem; we can easily create our own. All it is is a text file with the appropriate details listed in it.
Creating a .desktop File
On this test computer, we’ve got a program that doesn’t have a .desktop file.
The first thing to do is to check that the application runs. If it doesn’t, you’re not going to get it working with a .desktop file either. But you can spend a lot of time going round in circles wondering why your .desktop file doesn’t work. So, for the sake of being thorough, ensure you’re application launches and runs correctly when you start it manually.
A .desktop file is a text file with settings it in. On its own, that isn’t enough to display an icon. We need to use an icon that has been supplied with the application. We can see there is an icon called “ip_gc_icon.png” in the application directory, and we’ll use that.
We can also see that the binary file is called
gc . We’ll need that information shortly.
Open up an editor. We’re going to be using
gedit, but you can use the editor of your choice.
The first line of the .desktop file must be:
This identifies to Linux what it is you’re clicking on when you double-click it.
All of the other entries in the .desktop file are composed of labels and values, joined by an equals sign
=. Make sure you don’t have spaces directly before or after the equals 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 “Version” entry is the version number from the program.
- The “Name” entry is the name of the application. Note that we’ve included a locale identifier, [en_US], which means US English. You could leave it out. If you were creating a multi-lingual .desktop file, these types of identifiers would be required for each different language section. They won’t make any difference here, but they’re a good habit to get into.
- The “GenericName” entry is used to hold a generic description of the application. This could be used to hold descriptions such as “video editor,” “web browser,” or “word processor.” This application doesn’t fall into any particular category, so we’ll just give it a longer version of the application name.
- The “Comment” entry can hold any descriptive text you like.
The next three lines provide information to Linux so that it knows where the binary executable is, and which 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, this is the
- The “Path” entry is the path to the working directory for the application.
- The “Icon” entry is the path to the icon file that you wish to use for the desktop shortcut.
The last three lines are supplementary data regarding the application.
Terminal=false Type=Application Categories=Application
- The “Terminal” entry can be True or False. It indicates whether the application executes in a terminal or not. Our entry needs to be “false”.
- The “Type” entry can be one of Application, Link, or Directory. Obviously, we want our entry to be “Application”.
- The “Categories” entry may be used by Linux or GNOME to group similar or related applications in menus. We’re just going to enter a generic “Applications.”
A full list of possible .desktop file entries and their values can be found in the .desktop file specification.
Here’s our complete .desktop file:
Save the file into the application directory, making sure it has a “.desktop” file extension. Our example file is called “Geocoder.desktop.”
Copying the .desktop FIle To the Desktop
To copy the .desktop file onto the desktop, right-click it and select “Copy” from the context menu. Right-click on the desktop and select “Paste” from the context menu.
When you double click the icon on the desktop, you’ll see the same warning dialog as earlier. Click the “Trust and Launch” button.
The desktop icon will take on its true appearance, and the application will be launched.
Copying the .desktop FIle To the Applications Folder
As this program is going to be used by a single user, we’ll copy the .desktop file to his local applications directory. In the program directory, use this command:
cp ./Geocoder.desktop ~/.local/share/applications
Putting the .desktop file in the local applications directory integrates the application into the GNOME search function. Press the “Super” key (between the Control and Alt keys on the bottom-left of most keyboards) and type the first part of your application’s name. Its icon will appear in the search results.
- Left-Click it to launch the application.
- Right-click it and select “Add to favorites” to add it to your Ubuntu dock.
Ready for Launch
So there you have it. A little long-winded, but simple enough.
And definitely counter-intuitive.