.desktop file

1. What is a .desktop file?

In Linux, a .desktopfile is a shortcut for running a program, also called a launcher, or desktop item.

Basically a plain text file containing program information.

Without .desktopit, your app won't show up in the app menu.

2. The location of the .desktop file

.desktopFiles, usually placed in the ~/.local/share/applicationsor /usr/share/applications/directory.

3. How to create .desktop

Most apps automatically create files after installation .desktop. However, if it is a program you compiled from source code or an application in compressed format that you downloaded, it will not do these things . You need to open the terminal every time to execute its secondary file. Obviously this process is boring and cumbersome. At this time, you need to create the .desktop file manually.

To demonstrate, I'll create a .desktopfile for Super Tux Kart, a go-kart racing game that I enjoy playing.

Proceed as follows:

1. Download the tar package to the Downloads directory.

2. Unzip the compressed package

3. After decompression, enter the decompression directory, run the program, and make sure the program is running normally. You can double-click to run it, or run it in the terminal. If there is no executable permission, add executable permission first.

4. After confirming that the application is running normally, you can exit it. Then run your text editor and paste the following into an empty text file:

[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
Terminal=false
Exec=/path/to/executable
Name=Name of Application
Icon=/path/to/icon

You need to change the "Exec" value to the path to the executable file, and change the "Name" value to the name of the application . Most programs provide an icon in the zip file, don't forget to fill it in too. In our example, the Super Tux Kart startup file looks like this:

5. Save the application-name.desktopfile to ~/.local/share/applicationsthe directory with a name. .localThe directory is located under your home directory and is a hidden directory. You need to enable "Show Hidden Files" mode to see it.

If you want this application to be accessible to everyone, run the following command in the terminal:

sudo mv ~/.local/share/applications/<application-name.desktop> /usr/share/applications/

Of course, don't forget to  <application-name.desktop> change the command to the real  .desktop file name.

6. After completion, open the application menu and you will see that the application appears in it and is ready to be used.

Reprinted from: .desktop file-CSDN blog

Guess you like

Origin blog.csdn.net/fuhanghang/article/details/133376754