Similar to creating shortcuts on Windows 10, most applications, when installed, will automatically create a .desktop file and place it in the Application menu for quicker access with application shortcuts. However, if compiling a program from source or downloading an application in an archive format, you'll need to access the Terminal to execute the binary each time you want to use the application. Clearly, this consumes a lot of your precious time.
In the following article, Mytour will guide you on how to create a .Desktop file for applications on Linux, using it to launch applications on the Application menu more quickly.
How to Create .Desktop File for Applications on Linux
Essentially, a .desktop file is a simple text file containing information about a program. This file is typically located in “~/.local/share/applications” or “/usr/share/applications/”, depending on whether you want the launcher to be accessible only for the Local account or for everyone. Navigating to one of these directories in the File manager, you'll see corresponding .desktop files for the installed applications on your computer.
In this tutorial, Mytour will create a .desktop file for Super Tux Kart, a popular racing game. This game is available in the Ubuntu repository.
The only way to get the latest version is to download the tar archive repository, then extract and execute the file to launch the game.
You can apply these steps to any program you want to create a launcher for.
Note: The steps below assume you already have a repository file for the program you want to create a launcher for in the Downloads folder.
Step 1:
Step 2: After finishing the extraction process, open the newly extracted folder and locate the executable file. Right-click on the executable file, select Run to open the program to ensure it is functioning.
Step 3: In some cases, you may not find the Run option in the menu. This occurs because the executable file is a text file. In this case, you can open the executable file through the Terminal or if using GNOME, click on the File menu at the top corner, select Preferences.
Step 4: Next, choose the Behavior tab and select the option Run them under the Executable Text Files section. Now the Run option will appear in the menu when you right-click on the executable file.
Step 5: If you confirm that the application works when you run it, close that application. Then open a text editor and paste the following code into a blank 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
In the Exec field, change the path to the executable file and the Name field to the application name. Most programs will provide an icon in the repository, so don't forget to include that icon as well. In this example, the launcher file for Super Tux Kart looks like this:
Step 6: Save the file in the directory “~/.local/share/applications” as “application-name.desktop”. The “.local” directory is a hidden directory in the Home directory, so to display the directory, you need to activate the “Show Hidden Files” option. If you want to access for all accounts, you run the following command:
sudo mv ~/.local/share/applications/
Note to change
Step 7: Once completed, simply open the Application menu on the desktop screen, and you'll have access to the application.
Above is how to create a .Desktop file for applications on Linux. You can apply this method to all Linux-based operating systems. If you have any doubts or questions, please leave your comments below the post. Wish you all the best!