Running applications from the Terminal is useful at the beginning of the application making process. To have a fully working application integration in GNOME 3 requires a desktop launcher. For this you need to create a .desktop file. The .desktop file describes the application name, the used icon and various integration bits. A deeper insight to .desktop file can be found here.
The example shows you the minimum requirements for a .desktop file.
1 2 3 4 5 6 7 8 9 10 11
[Desktop Entry] Version=1.0 Encoding=UTF-8 Name=HelloWorld Comment=Say Hello Exec=helloWorld.js Icon=application-default-icon Terminal=false Type=Application StartupNotify=true Categories=GNOME;GTK;Utility;
Now let's go through some parts of the .desktop file.
Line 4: Name of the application
Line 5: Specifies a short description of the item
Line 6: Specifies a command to execute when you choose the item from the menu. In this example exec just tells where to find the helloworld.js file and the file takes care of the rest.
Line 8: Specifies whether the command in the Exec key runs in a terminal window.
If you want your .desktop file to exist as a part of the system, copy your .desktop file to this directory: ~/.local/share/applications
To put your application to the right category you need to add the necessary categories to the Categories line. More information on the different categories can be found in the menu spec.
In this example I used an existing icon. For a custom icon you need to have a .svg file of your icon, store it to /usr/share/icons/hicolor/scalable/apps. Write the name of your icon file to the .desktop file, on line 7. More information on icons in: Installing Icons for Themes , Installing Icons for Themes and on freedesktop.org: Specifications/icon-theme-spec.
After you have finished writing the .desktop file you must change it's permissions to allow executing file as program. To do that, go to the folder containing the .desktop file. Right click the .desktop file, choose properties and tab permissions and place a check on the box after Execute:
Got a comment? Spotted an error? Found the instructions unclear? Send feedback about this page.