Skip to content

Desktop Entry In Linux

Posted on:October 2, 2024 at 04:45 PM

tp.web.random_picture

Create a desktop entry in Linux to launch applications

Table of contents

Open Table of contents

TL;DR

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:

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:

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.