Desktop files are intended as shortcuts to applications. They are plain text files ending in the .desktop extension and following a standard format. Here is a simple example of a desktop file to launch Dolphin, the KDE file manager:
xdg-open is a program that will open a file in the preferred application.
In the above example we have only several fields, but they are enough to contain everything needed to know about the program:
The Name field specifies the name of the application
The GenericName field specifies a description of the application
The Type field specifies the type of the application
The Exec field specifies the executable program or script to be launched when running the desktop file
The Icon field specifies the icon to be used by the desktop file
Example of editing a desktop file:
Usually desktop environments will recognize a desktop file and display its name from the Name section instead of the filename which could be something like launch-dolphin.desktop.
All you have to do is create such a desktop file using a text editor like Gedit or Nano, and also make sure to give execute permissions to your desktop file, e.g. chmod 755 launch-dolphin.desktop, so the program xdg-open will be ran automatically. You can then drag and drop your desktop files on the desktop or to a panel.
Here is an example for running an application in System Tray using the AllTray program, using the command alltray dolphin:
AllTray is an application docker and it will integrate any graphical application in the system tray. For terminal applications, follow the next example.
Or, for example to run a terminal application, using alltray konsole -e irssi, which will launch Konsole and start up the IRC client Irssi inside it:
Exec=alltray konsole -e irssi
Creating a Desktop File in KDE
Right-click in a directory and choose Create New-Link to Application…:
In the General tab, choose the name of your shortcut and then click the icon button to choose an icon for your launcher:
In the Application tab, fill in the Name, Description and Command fields:
That is all. If you right-click your desktop file now and open it with a text editor, it should look something like this, pretty much the same as creating it manually:
By Craciun Dan on March 07, 2014 | Updated: March 07, 2014 | v0.2.0 r1