Use desktop entry files to add an application to the desktop menu
Desktop entry files are used to add an application to the desktop menu. These files specify the name and icon of your application, the categories it belongs to, related search keywords and more. These files have the extension .desktop and follow the XDG Desktop Entry Specification version 1.1.
You do that by creating a .desktop
file and saving it in ~/.local/share/applications/
Here’s a basic .desktop
file
1# ~/.local/share/applications/obsidian.desktop
2[Desktop Entry]
3Type=Application
4Name=Obsidian
5Exec=/home/aamnah/Mounts/Files/Applications/Obsidian-0.13.19.AppImage
6Icon=/home/aamnah/Mounts/Files/Applications/obsidian.png
Type
and a Name
key and can optionally define its appearance in the application menu. In other words only Type
and Name
are required, rest are all optionalType
and Name
, you will most likely addExec
to specify where the executable is (or a specific command to execute with arguments)Icon
to specify which icon to show with the executable (this icon will show in the Launcher and in the Dock).desktop
absolute to avoid troubleshooting headaches.desktop
files1# for applications installed system-wide
2/usr/share/applications/
3/usr/local/share/applications/
4
5# for user-specific applications
6~/.local/share/applications/
If you’re specifying an AppImage (or any other script) as value for Exec
, make sure it is executable
sudo chmod u+x /home/aamnah/Mounts/Files/Applications/Obsidian.AppImage
After you have added a .desktop
file, run the following command to update cache database of MIME types handled by desktop files. (Although Unity picked up my entry without me having to refresh anything)
1update-desktop-database ~/.local/share/applications
Here’s a working copy of my complete obsidian.desktop
file
1# ~/.local/share/applications/obsidian.desktop
2[Desktop Entry]
3Type=Application
4Name=Obsidian
5Comment=A second brain, for you, forever.
6Terminal=false
7
8GenericName=Markdown Editor
9# StartupWMClass=obsidian
10# MimeType=x-scheme-handler/obsidian;
11
12# Location for the AppImage file and icon
13# Exec=/home/aamnah/Mounts/Files/Applications/Obsidian-0.13.19.AppImage %u
14Exec=/home/aamnah/Mounts/Files/Applications/Obsidian-0.13.19.AppImage
15Icon=/home/aamnah/Mounts/Files/Applications/obsidian.png
16
17
18# Download icon and place it in the same folder as this one
19# curl -L -o obsidian.png https://cdn.discordapp.com/icons/686053708261228577/1361e62fed2fee55c7885103c864e2a8.png
You may have to make the file executable as well