Create Desktop Icon

From HIO Wiki
Jump to: navigation, search

About

This tutorial will show how to create basic icons to execute applications for Yocto Embedded Linux operate with X Window. For more information about technical details, visit freedesktop.org
The *.desktop file fills two primary functions. one is to informs the desk environment how to handle the applications. E.g. associate name and description of the application, display of icons, recognize the MIME types it supports for opening files. The second one is a direct shortcut to the desktop.
Most of the *.desktop files are located in /usr/share/applications and their respective icons are located in /usr/share/pixmaps

Key Elements

The table below cover some basic elements that are used inside the *.desktop file.

Description
Required Elements
Type This defines the 3 valid type of desktop entries: Application,Link,or Directory
Name The specific name of the application
Exec Provide absolute path for program to execute, possibly with arguments.
Optional Elements
Icon Icon to display for the application; If specified in absolute path, the corresponding file will be used. Otherwise, the system will specify the icon.
Terminal Boolean value to specify whether application type programs should run in the terminal.
Comment Specify the tooltip entries, should not be redundant with the values of Name
Categories Specify which categories the entry should be shown in the desktop
StartupNotify Boolean value to enable the desktop to use whatever built-in startup notification.
MimeType Specify the MIME type supported by the application
SingleInstance Boolean value to specify whether the program can run in again when it is already running

Instruction

To create a Desktop Icon:

  • In the embedded device, change directory to /usr/share/applications
  • Create a new file *.desktop, e.g. Cube.desktop
  • Input the required elements
  • Input the optional elements
  • Save the *.desktop file
  • The desktop icon should automatically appear in the desktop. Otherwise, restart the device.

Examples

Example of Qt5 Cube.desktop

[Desktop Entry]
Name=Qt3D Basket
Exec=/usr/share/qt5/examples/qt3d/cube
Icon=qt5basket
Terminal=false
Type=Application
X-MB-SingleInstance=true
Comment=Qt3D Cube Desktop Icon Example
StartupNotify=false

Example of mozilla-firefox.desktop

[Desktop Entry]
Name=Firefox Browser
Comment=Firefox Web Browser
Exec=firefox
Terminal=false
MultipleArgs=false
Type=Application
Icon=/usr/share/icons/firefox.png
Categories=Application;Internet;Network;
SingleInstance=true

For more examples, visit any ubuntu desktop files located in /usr/share/applications