Difference between revisions of "Development/Tutorials/Desktop File"

Jump to: navigation, search
m (cmake based projects)
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Template:I18n/Language Navigation Bar|Development/Tutorials/Desktop File}}
+
 
  
 
{{TutorialBrowser|
 
{{TutorialBrowser|
Line 7: Line 7:
 
name=Desktop File|
 
name=Desktop File|
  
pre=[[Development/Tutorials/Session_Management|Session Management]]|
+
pre=|
  
 
next=|  
 
next=|  
Line 55: Line 55:
 
=== cmake based projects ===
 
=== cmake based projects ===
 
In case you are working on a cmake based project, add an install directive to your CMakeLists.txt file like this:
 
In case you are working on a cmake based project, add an install directive to your CMakeLists.txt file like this:
  install( PROGRAMS your-app.desktop DESTINATION ${[Development/CMake/Addons_for_KDE#The_locations_of_install_directories|XDG_APPS_INSTALL_DIR]} )
+
  install( PROGRAMS your-app.desktop DESTINATION ${[[Development/CMake/Addons_for_KDE#The_locations_of_install_directories|XDG_APPS_INSTALL_DIR]]} )
  
 
An example CMakeLists.txt file can be found [http://quickgit.kde.org/?p=kdepim.git&a=blob&hb=18742d763bc8a2d2c2c7ef433cc66c39b6a95036&f=ktimetracker/support/CMakeLists.txt here]. The corresponding .desktop file is [http://quickgit.kde.org/?p=kdepim.git&a=blob&hb=63798b547ecb595d166cdbe2e0a04d985fcc8980&f=ktimetracker/support/ktimetracker.desktop here].
 
An example CMakeLists.txt file can be found [http://quickgit.kde.org/?p=kdepim.git&a=blob&hb=18742d763bc8a2d2c2c7ef433cc66c39b6a95036&f=ktimetracker/support/CMakeLists.txt here]. The corresponding .desktop file is [http://quickgit.kde.org/?p=kdepim.git&a=blob&hb=63798b547ecb595d166cdbe2e0a04d985fcc8980&f=ktimetracker/support/ktimetracker.desktop here].

Revision as of 18:00, 19 July 2012


Desktop File
Tutorial Series   Basics
Previous  
What's Next  
Further Reading   the .desktop Free Desktop Spec;

Contents

Desktop File

In order for your application to show up in menus and/or to be automatically associated with mime types in file browsers, you need to provide a .desktop file like follows:

[Desktop Entry]
Type=Application
Exec=your-app %u
MimeType=application/x-your-mime-type;
Icon=some-icon
X-DocPath=yourapp/index.html
Terminal=false
Name=Your App
GenericName=Some Generic Name
Comment=Short Description Of Your App
Categories=Qt;KDE;

Take a look at the .desktop Free Desktop Spec to find our more about the key/value pairs above. It's important to pick a good set of Categories, see the spec for a list of valid values.

Your project

You want your project to show up in the K Menu like this:

Snapshot-k-menu.png

In this example, the application is called quickpen and it shows up in the category "Graphics". To accomplish that in your project you need to take care the .desktop file is distributed to the appropriate place.

qmake based projects

In case you are working on a qmake based project, add the following to your .pro file:

target.path = /usr/local/bin
desktop.path = /usr/share/applications
desktop.files += your-app.desktop
INSTALLS += target desktop

Note that the bold strings above should be in your project anyway.

An example .pro file can be found here. The related .desktop file can be found here.

cmake based projects

In case you are working on a cmake based project, add an install directive to your CMakeLists.txt file like this:

install( PROGRAMS your-app.desktop DESTINATION ${XDG_APPS_INSTALL_DIR} )

An example CMakeLists.txt file can be found here. The corresponding .desktop file is here.

See also


KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V.Legal