I have an application that I start only from the command line. How can I add the command (and preferably a nice logo) to Gnome's application menu?
In GNOME and other freedesktop.org-compliant desktop environments, such as KDE and Unity, applications are added to the desktop's menus or desktop shell via desktop entries, defined in text files with the
.desktop extension (referred to as desktop files). The desktop environments construct menus for a user from the combined information extracted from available desktop entries.
Desktop files may be created in either of two places:
/usr/share/applications/for desktop entries available to every user in the system
~/.local/share/applications/for desktop entries available to a single user
You might need to restart GNOME for the new added applications to work.
Per convention, desktop files should not include spaces or international characters in their name.
Each desktop file is split into groups, each starting with the group header in square brackets (
). Each section contains a number of key, value pairs, separated by an equal sign (
Below is a sample of desktop file:
[Desktop Entry] Type=Application Encoding=UTF-8 Name=Application Name Comment=Application description Icon=/path/to/icon.xpm Exec=/path/to/application/executable Terminal=false Categories=Tags;Describing;Application
Desktop Entrygroup header identifies the file as a desktop entry
Typethe type of the entry, valid values are
Encodingthe character encoding of the desktop file
Namethe application name visible in menus or launchers
Commenta description of the application used in tooltips
Iconthe icon shown for the application in menus or launchers
Execthe command that is used to start the application from a shell.
Terminalwhether the application should be run in a terminal, valid values are
;) separated list of menu categories in which the entry should be shown
Command line arguments in the
Exec key can be signified with the following variables:
%fa single filename.
%ua single URL.
%da single directory. Used in conjunction with
%fto locate a file.
%Dmultiple directories. Used in conjunction with
%Fto locate files.
%na single filename without a path.
%Nmultiple filenames without paths.
%ka URI or local filename of the location of the desktop file.
%vthe name of the Device entry.
~ or environmental variables like
$HOME are not expanded within desktop files, so any executables referenced must either be in the
$PATH or referenced via their absolute path.
If the application to be launched requires certain steps to be done prior to be invoked, you can create a shell script which launches the application, and point the desktop entry to the shell script. Suppose that an application requires to be run from a certain current working directory. Create a launch script in a suitable to location (
~/bin/ for instance). The script might look something like the following:
#!/bin/bash pushd "/path/to/application/directory" ./application "$@" popd
Set the executable bit for the script:
$ chmod +x ~/bin/launch-application
Then point the
Exec key in the desktop entry to the launch script:
Very good answer from Thomas Nyman.
Gnome comes with gui tool
gnome-desktop-item-edit assisting in creating *.desktop files.
We need to use it from command line, or create a desktop file for it.
Instructions to make Gnome Application from
Open terminal windows and type the following command:
gnome-desktop-item-edit --create-new /home/[your user name]/.local/share/applications
In the opened window fill the following:
Name: Gnome Applicaiton
Command: gnome-desktop-item-edit --create-new /home/[your user name]/.local/share/applications
Click on the icon to select a different icon.
Click OK to close the windows
Close the terminal window
Testing newly generated
- Open dash
- Type Application
- You should see the
Gnome Applicationentered before
- Select it
- Create another application
To create for all users use:
sudo gnome-desktop-item-edit --create-new /usr/share/applications
If the command is missing on debian/ubuntu try:
sudo apt-get install gnome-panel
The previous answers from Thomas Nyman and Dudi Boy are very good and detailed. I am posting this because I didn't found a answer for my doubt in any other posts and I had to search in git issues.
After I followed the steps like Thomas Nyman suggested I have been able to make the icon for my program to appear in the App Menu. The problem here is that I use Dash to Dock as side bar and I could not pin the icon as a favourite like other icons. After searching I found that you need to add the line
After that the option to add to favourites will appear by right clicking on the icon in Dash to Dock.
A graphical solution is to install MenuLibre
It is available for Ubuntu-flavored distributions via
apt install menulibre
or you can install it from source
It allows to categorize apps per Gnome categories and plays well with Chrome apps.