- Saved searches
- Use saved searches to filter your results more quickly
- License
- CookieCrumbs19212/Guide-to-Create-Desktop-Entries
- Name already in use
- Sign In Required
- Launching GitHub Desktop
- Launching GitHub Desktop
- Launching Xcode
- Launching Visual Studio Code
- Latest commit
- Git stats
- Files
- README.md
- How to Create a .Desktop File for Your Application in Linux
- Content
- How to Create Desktop Launchers
- How to Copy .Desktop Files
- How to Create .Desktop Files With a Third-Party Program
- Frequently Asked Questions
- Is it possible to use a .desktop file even if I am using a window manager?
- Is it possible to create a .desktop file for CLI and TUI applications using Arronax?
- Is it possible to hide a desktop shortcut from an Application Menu?
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
Guide to creating .desktop files in Linux.
License
CookieCrumbs19212/Guide-to-Create-Desktop-Entries
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Sign In Required
Please sign in to use Codespaces.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
Git stats
Files
Failed to load latest commit information.
README.md
Guide to Create a Linux Desktop Entry
How to create a desktop entry?
Desktop entries are created using .desktop files. These files allow your application (or any executable) to show up in the Application Launcher.
Step 1: Choose where to save the .desktop file
Is this desktop entry for all users or just you?
Decide whether you want to create the desktop entry for all users in your system or just for yourself. If you choose to create the desktop entry for all users, it will show up in the application launcher of every user in the system. Depending on the situation, you may or may not want everyone in the system to have the desktop entry pop up in their application launcher.
NOTE: You require root access to create the desktop entry for all users.
TIP: When creating a desktop entry for all users, ensure that the executable file and app icon file are located in a directory accessable by root and outside any local user’s file structure.
Option 1: Create a desktop entry for all users:
First you’ll need to enable root privileges.
Then enter the root password. This should give you root privileges.
Next, cd to the /usr/share/applications/ directory.
Option 2: Create a desktop entry just for yourself:
cd to the ~/.local/share/applications/ directory.
$ cd ~/.local/share/applications/
Step 2: Create the .desktop file
Let’s say our application’s name is foo. Then we will create the desktop file foo.desktop to store the desktop entry.
Step 3: Edit the .desktop file
Open the .desktop file you just created in your preferred code editor and paste the following code:
[Desktop Entry] Encoding=UTF-8 Version=1.0.0 Type=Application Terminal=false Exec=/path/to/executable/file Name=Name of Application Icon=/path/to/application/icon/file
Let’s elaborate on the important variables:
Variable | Description |
---|---|
Version | The version of the application, it is not a critical variable but you are free to modify it to reflect the version of the application. |
Terminal | When set to true , a terminal will open up and run the executable. When set to false , the terminal is not opened up. |
Exec | Absolute path to the executable file. All Linux executable files are accepted; shell, bin, etc. |
Name | The name of your application. This is the name that will be displayed in the application launcher and show up in searches. |
Icon | Absolute path to the application icon file. The icon file can be almost any image file format. With that said, PNG format is desirable as it gives you the freedom of the alpha channel which allows for transparent backgrounds in the icon. |
Remember to save the changes made to the .desktop file.
And that’s it, you have successfully created a desktop entry for your executable.
How to Create a .Desktop File for Your Application in Linux
A .desktop file is simply a shortcut that is used to launch applications in Linux. Without the .desktop file, your application won’t show up in the Applications menu and can’t be launched with third-party launchers such as Ulauncher and Albert.
Most applications, when installed, will create the .desktop files automatically and place themselves in the “Application” menu for quick access. However, if you compile a program from source or download an app in archive format, this may not be the case, and you may have to open the terminal to execute the binary every time you want to use it. Obviously, this can become a very tedious and troublesome step. This tutorial shows how you can create a .desktop file for any application you use that can be launched from the “Application” menu.
Content
How to Create Desktop Launchers
A .desktop file is a simple text file that holds information about a program. It is usually placed in “~/.local/share/applications” or “/usr/share/applications/,” depending on whether you want the launcher to be accessible for your local account onlly or for everyone. If you navigate to either directory in your File Manager, you will see quite a few .desktop files that correspond with the installed apps on your computer.
For demonstration purposes, we are creating a .desktop file for Super Tux Kart, a kart racing game we like to play sometimes. A version is available in the Ubuntu repos, but this is often behind the latest stable version.
The only way to get the latest and greatest release is by downloading a tar archive, extracting it and executing a file which will launch the game.
You can follow along with whichever program you want to create a launcher for, and it should work the same way.
Note: the following steps assume you have the archive for the program you want to create a launcher for in your “Downloads” folder.
- Once the extraction is complete, change to the newly created folder and find the executable.
- Right-click it and select “Run as a Program” to launch the program just to ensure it is working.
- In some cases, you won’t see the “Run” option in the menu, often because the executable is a .text file. You can get around this by executing it via the terminal.
- If you’ve confirmed that the application works when you launch it, you can exit it.
- Launch your text editor and paste the following into the 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
Note: You’ll need to change the “Exec” field to the path to the executable and “Name” field to the name of the application. Most programs provide an icon somewhere in the archive, so don’t forget to include that as well. In our case, the launcher file for Super Tux Kart looks like the following image.
- Save the file in the “~/.local/share/applications” folder as “application-name.desktop”. The “.local” folder is a hidden folder in your “Home” directory and “Show Hidden Files” mode will have to be enabled for you to view it. If you want it to be globally accessible, run the following command in the terminal:
sudo mv ~/.local/share/applications/application-name.desktop> /usr/share/applications/
Note: don’t forget to change to the actual name of the .desktop file.
The method described here should work on all mainstream Linux-based operating systems. Here’s another screenshot showing Super Tux Kart in Xubuntu’s application launcher (XFCE).
How to Copy .Desktop Files
As discussed above, you can obtain a .desktop file from a program that you have installed through a repository. This is helpful if you want to create a custom .desktop file as a way of fixing a broken package in Ubuntu.
For the most part, each Linux distribution is largely similar in its structure, so while this section will heavily focus on Ubuntu 22.04, you can still use these instructions in your favorite desktop environment.
- To start, open a File Manager from your desktop. In this case, we are opening Nautilus, as it is the default for Ubuntu.
- Press the “Other Locations” entry in Nautilus’s left side bar.
- Go to “/usr/share/applications.” This directory contains the .desktop files that your desktop manager uses to create its Application Menu.
- Copy the application you want to create a shortcut to. For instance, right-click on “firefox-esr.desktop” and select “Copy.”
- Right-click on your .desktop file and select “Allow Launching.” Doing this will set the permission bits so that your desktop environment can use this file to launch your program.
How to Create .Desktop Files With a Third-Party Program
Aside from editing and copying .desktop files, it is also possible to create shortcuts in Linux through a Graphical User Interface (GUI) program. This is useful if you are not comfortable with editing configuration files.
Unlike the previous methods, this will require you to install a program like Arronax, which may not be present in your distribution’s repository. Despite that, it is still possible to use it by obtaining a copy from the developer’s website. To install the GUI in Ubuntu, follow the below instructions.
sudo add-apt-repository ppa:diesche/stable
- On the other hand, if you are installing it through a tarball, you need to unpack the archive using tar:
tar xvzf /home/$USER/Downloads/arronax-0.8.1.tar.gz
- Run Arronax by either running the command below or typing “arronax” while in the Application Menu. This will bring up a window where you can create and save .desktop files.
- To create your first shortcut using Arronax, click the “New” icon in Arronax’s Menu Bar to create a template that you can use for your shortcut.
- Provide the shortcut’s name and a file path to your program. For example, we are creating a .desktop file for Firefox by typing “Firefox” in the “Title” field and /bin/firefox-esr in the “Command” field.
- Right-click this .desktop file and select “Allow Launching” to set the permission bits for it, as shown above.
Frequently Asked Questions
Is it possible to use a .desktop file even if I am using a window manager?
No, a .desktop file will not work on most window managers, as it lacks the necessary support for the “XDG Menu” specification. While it is possible to create a .desktop file in a window manager, it will not show up as a desktop shortcut. One way to recreate this mechanism is by using shell scripts alongside the Simple X Hotkey Daemon.
Is it possible to create a .desktop file for CLI and TUI applications using Arronax?
Yes! You can easily create a .desktop file for a program that runs in the terminal, which is useful if you are already using TUI programs and want to have a quick way to access them.
To do this using Arronax, create a new .desktop shortcut by providing both a “Title” and a “Command,” then toggle the “Run in Terminal” option and save the new shortcut.
Is it possible to hide a desktop shortcut from an Application Menu?
Yes! It is possible to modify a .desktop file to not show on your Applications Menu by adding a single line of code in the file that you want to edit. For example, if you want to hide Firefox from your Applications Menu, open the “firefox-esr.desktop” file in “/usr/share/applications”. From there, add Hidden=true at the end of the file, then restart your computer to apply the changes.
Image credit: Charles-Adrien Fournier via Unsplash All screenshots by Ramces Red.
Ramces is a technology writer that lived with computers all his life. A prolific reader and a student of Anthropology, he is an eccentric character that writes articles about Linux and anything *nix.
Our latest tutorials delivered straight to your inbox