Create a desktop entry in Linux to launch applications
Table of contents
Open Table of contents
TL;DR
- Desktop entries are configuration files to launch applications in Linux.
- Use a text editor to create a
.desktop
file with necessary fields likeName
,Exec
,Icon
,Type
,Categories
, andStartupNotify
. - Save the file, set executable permissions, and place it in
~/.local/share/applications/
or/usr/share/applications/
.
Example
Here is an example of a desktop entry file for a text editor called MyEditor
:
[Desktop Entry]
Name=MyEditor
Exec=/usr/bin/myeditor
Icon=/usr/share/icons/myeditor.png
Type=Application
Categories=Utility
StartupNotify=true
In this example, the desktop entry file is named myeditor.desktop
and it launches the MyEditor
text editor. The executable file of the text editor is located at /usr/bin/myeditor
and the icon file is located at /usr/share/icons/myeditor.png
.
Introduction
Desktop entries are the configuration files used to launch applications in Linux. These files are used to create shortcuts for applications in the desktop environment. In this article, we will learn how to make a desktop entry in Linux.
Prerequisites
Before you start creating a desktop entry, you need to have the following prerequisites:
- A text editor like Nano or gedit
- Basic knowledge of Linux commands
Steps to create a desktop entry
Here are the steps to create a desktop entry in Linux:
Step 1: Create a file with .desktop
extension
Open a text editor like nano or gedit and create a new file with the .desktop
extension. For example, you can create a file named myapplication.desktop
.
Step 2: Add content to the desktop entry file
Add the following content to the desktop entry file:
[Desktop Entry]
Name=My Application
Exec=/path/to/application executable.
Icon=/path/to/icon file.
Type=Application
Categories=Development
StartupNotify=true
In the above content, replace the following fields with the appropriate values:
Name
: The name of the application.Exec
: The path to the executable file of the application.Icon
: The path to the icon file of the application.Type
: The type of the application. There are three types of applications: Application, Link, and Directory. However, the most common type is Application and we will use it in this example.Categories
: The categories of the application.StartupNotify
: Whether the application should notify the user when it starts.
Step 3: Save the file and update the permissions
Save the file and exit the text editor. Set the executable permission on the desktop entry file using the following command:
chmod +x myapplication.desktop
Step 4: Place the desktop entry file in the appropriate directory
After creating the desktop entry file, you can move it to the appropriate directory to make it available in the desktop environment. The most common directory to place the desktop entry file is ~/.local/share/applications/
. You can also place the desktop entry file in /usr/share/applications/
to make it available system-wide.
Step 5: Test the desktop entry
After placing the desktop entry file in the appropriate directory, you can test it by searching for the application in the application menu or launcher of your desktop environment. Click on the application icon to launch the application.
Conclusion
In this article, we learned how to create a desktop entry in Linux. Desktop entries are the configuration files used to launch applications in Linux. These files are used to create shortcuts for applications in the desktop environment.