TDE core libraries
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

DESKTOP_ENTRY_STANDARD 30KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  1. ----------------------------------------------------------------------------------------------------------------------------
  2. Desktop Entry Standard
  3. Preston Brown
  4. <pbrown@kde.org>
  5. Jonathan Blandford
  6. <jrb@redhat.com>
  7. Owen Taylor
  8. <otaylor@gtk.org>
  9. Version 0.9.4
  10. ----------------------------------------------------------------------------------------------------------------------------
  11. Table of Contents
  12. Introduction
  13. Basic format of the file
  14. Possible value types
  15. Recognized desktop entry keys
  16. Character set encoding of the file
  17. List of valid Exec parameter variables
  18. Detailed discussion of supporting MIME types
  19. Extending the format
  20. A. Example Desktop Entry File
  21. B. Currently reserved for use within KDE
  22. C. Deprecated Items
  23. D. The Legacy-Mixed encoding (Deprecated)
  24. Introduction
  25. Both the KDE and GNOME desktop environments have adopted a similar format for "desktop entries," or configuration files
  26. describing how a particular program is to be launched, how it appears in menus, etc. It is to the larger community's benefit
  27. that a unified standard be agreed upon by all parties such that interoperation between the two environments, and indeed any
  28. additional environments that implement the specification, becomes simpler.
  29. Basic format of the file
  30. These desktop entry files should have the extension ".desktop". Determining file type on basis of extension makes determining
  31. the file type very easy and quick. When no file extension is present, the desktop system should fall back to recognition via
  32. "magic detection." Desktop entries which describe how a directory is to be formatted/displayed should be simply called
  33. ".directory".
  34. The basic format of the desktop entry file requires that there be a "group" header named "[Desktop Entry]". This "group" entry
  35. denotes that all {key,value} pairs following it belong in the Desktop Entry group. There may be other groups present in the file
  36. (see MIME types discussion below), but this is the most important group which explicitly needs to be supported. This group
  37. should also be used as the "magic key" for automatic mime type detection. There should be nothing proceeding this group in the
  38. desktop entry file but possibly one or more comments (see below).
  39. Group headers may not contain the characters '[' and ']' as those delimit the header.
  40. Lines beginning with a "#" and blank lines are considered comments and will be ignored, however they should be preserved across
  41. reads / writes of the desktop entry file.
  42. Compliant implementations MUST not remove any fields from the file, even if they don't support them. Such fields must be
  43. maintained in a list somewhere, and if the file is "rewritten," they will be included. This ensures that any desktop-specific
  44. extensions will be preserved even if another system accesses and changes the file.
  45. Entries in the file are {key,value} pairs in the format:
  46. Name=Value
  47. Space before and after the equals sign should be ignored; the "=" sign is the actual delimiter.
  48. The escape sequences \s, \n, \t, \r, and \\ are supported, meaning ASCII space, newline, tab, carriage return, and backslash,
  49. respectively.
  50. Possible value types
  51. The value types recognized are string, localestring, regexp, boolean (encoded as the string true/false), and numeric.
  52. The difference between string and localestring is that the value for a string key must contain only ASCII characters and while
  53. the value of a localestring key may contain UTF-8 characters. (See section 5.)
  54. Some keys can have multiple values; these should be separated by a semicolon. Those keys which have several values should have a
  55. semicolon as the trailing character. For lists of strings, semicolons are simply not allowed in the strings, there is no escape
  56. mechanism.
  57. Recognized desktop entry keys
  58. Keys with type localestring may be postfixed by [LOCALE], where LOCALE is the locale type of the entry. LOCALE must be of the
  59. form lang[_COUNTRY][ ENCODING][ MODIFIER], where _COUNTRY, .ENCODING, and @MODIFIER may be omitted. If a postfixed key occurs,
  60. the same key must be also present without the postfix.
  61. When reading in the desktop entry file, the value of the key is selected by matching the current POSIX locale for the
  62. LC_MESSAGES category against the locale postfixes of all occurrences of the key, with the .ENCODING part stripped. The .ENCODING
  63. field is used only when the Encoding key for the desktop entry file is Legacy-Mixed, (see Appendix D.)
  64. The matching of is done as follows. If LC_MESSAGES is of the form LANG_COUNTRY.ENCODING@MODIFIER, then it will match a key of
  65. the form LANG_COUNTRY@MODIFIER. If such a key does not exist, it will attempt to match LANG_COUNTRY followed by LANG@MODIFIER.
  66. Then, a match against LANG by itself will be attempted. Finally, if no matching key is found the required key without a locale
  67. specified is used. The encoding from the LC_MESSAGES value is ignored when matching.
  68. If LC_MESSAGES does not have a MODIFIER field, then no key with a modifier will be matched. Similarly, if LC_MESSAGES does not
  69. have a COUNTRY field, then no key with a country specified will be matched. If LC_MESSAGES just has a LANG field, then it will
  70. do a straight match to a key with a similar value. The following table lists possible matches of various LC_MESSAGES in the
  71. order in which they are matched. Note that the ENCODING field isn't shown.
  72. Table 1. Locale Matching
  73. +-------------------------------------------------------------------------------------------------+
  74. | LC_MESSAGES Value | Possible Keys in Order of Matching |
  75. |-----------------------+-------------------------------------------------------------------------|
  76. | LANG_COUNTRY@MODIFIER | LANG_COUNTRY@MODIFIER, LANG_COUNTRY, LANG@MODIFIER, LANG, Default Value |
  77. |-----------------------+-------------------------------------------------------------------------|
  78. | LANG_COUNTRY | LANG_COUNTRY, LANG, Default Value |
  79. |-----------------------+-------------------------------------------------------------------------|
  80. | LANG@MODIFIER | LANG@MODIFIER, LANG, Default Value |
  81. |-----------------------+-------------------------------------------------------------------------|
  82. | LANG | LANG, Default Value |
  83. +-------------------------------------------------------------------------------------------------+
  84. For example, if the current value of the LC_MESSAGES category is sr_YU Latn and the desktop file includes:
  85. Name=Foo
  86. Name[sr_YU]=...
  87. Name[sr Latn]=
  88. Name[sr]=...
  89. then the value of the Name keyed by "sr_YU" is used.
  90. Case is significant. The keys "Name" and "NAME" are not equivalent. The same holds for group names. Key values are case
  91. sensitive as well.
  92. Keys are either OPTIONAL or REQUIRED. If a key is optional it may or may not be present in the file. However, if it isn't, the
  93. implementation of the standard should not blow up, it must provide some sane defaults. Additionally, keys either MUST or MAY be
  94. supported by a particular implementation.
  95. Some keys only make sense in the context when another particular key is also present.
  96. Some example keys: Name[C], Comment[it].
  97. Table 2. Standard Keys
  98. +------------------------------------------------------------------------------------------------------------------------------+
  99. | Key | Description | Value Type | REQ? | MUST? | Type |
  100. |------------------------+----------------------------------------------------------------+--------------+------+-------+------|
  101. | Type | There are 4 types of desktop entries: Application(1), Link(2), | string | YES | YES | |
  102. | | FSDevice(3) and Directory(4). | | | | |
  103. |------------------------+----------------------------------------------------------------+--------------+------+-------+------|
  104. | | Version of Desktop Entry Specification (While the version | | | | |
  105. | | field is not required to be present, it should be in all newer | | | | |
  106. | Version | implementations of the Desktop Entry specification. If the | numeric | NO | YES | 1-4 |
  107. | | version number is not present, a "pre-standard" desktop entry | | | | |
  108. | | file is to be assumed). | | | | |
  109. |------------------------+----------------------------------------------------------------+--------------+------+-------+------|
  110. | Encoding | Encoding of the whole desktop entry file (UTF-8 or | string | YES | YES | 1-4 |
  111. | | LegacyMixed). | | | | |
  112. |------------------------+----------------------------------------------------------------+--------------+------+-------+------|
  113. | Name | Specific name of the application, for example "Mozilla". | localestring | YES | YES | 1-4 |
  114. |------------------------+----------------------------------------------------------------+--------------+------+-------+------|
  115. | GenericName | Generic name of the application, for example "Web Browser". | localestring | NO | YES | 1-4 |
  116. |------------------------+----------------------------------------------------------------+--------------+------+-------+------|
  117. | | NoDisplay means "this application exists, but don't display it | | | | |
  118. | | in the menus". This can be useful to e.g. associate this | | | | |
  119. | NoDisplay | application with mimetypes, so that it gets launched from a | boolean | NO | NO | 1-4 |
  120. | | file manager (or other apps), without having a menu entry for | | | | |
  121. | | it (there are tons of good reasons for this, including e.g. | | | | |
  122. | | the netscape -remote, or kfmclient openURL kind of stuff). | | | | |
  123. |------------------------+----------------------------------------------------------------+--------------+------+-------+------|
  124. | Comment | Tooltip for the entry, for example "View sites on the | localestring | NO | YES | 1-4 |
  125. | | Internet"; should not be redundant with Name or GenericName. | | | | |
  126. |------------------------+----------------------------------------------------------------+--------------+------+-------+------|
  127. | | Icon to display in file manager, menus, etc. If the name is an | | | | |
  128. | | absolute path, the given file will be used. If the name is not | | | | |
  129. | Icon | an absolute path, an implementation-dependent search algorithm | string | NO | YES | 1-4 |
  130. | | will be used to locate the icon. Icons may be localized with | | | | |
  131. | | the Icon[xx]= syntax. | | | | |
  132. |------------------------+----------------------------------------------------------------+--------------+------+-------+------|
  133. | | Hidden should have been called Deleted. It means the user | | | | |
  134. | | deleted (at his level) something that was present (at an upper | | | | |
  135. | | level, e.g. in the system dirs). It's strictly equivalent to | | | | |
  136. | Hidden | the .desktop file not existing at all, as far as that user is | boolean | NO | NO | 1-4 |
  137. | | concerned. This can also be used to "uninstall" existing files | | | | |
  138. | | (e.g. due to a renaming) - by letting "make install" install a | | | | |
  139. | | file with Hidden=true in it. | | | | |
  140. |------------------------+----------------------------------------------------------------+--------------+------+-------+------|
  141. | | A list of regular expressions to match against for a file | | | | |
  142. | FilePattern | manager to determine if this entry's icon should be displayed. | regexp(s) | NO | NO | 1 |
  143. | | Usually simply the name of the main executable and friends. | | | | |
  144. |------------------------+----------------------------------------------------------------+--------------+------+-------+------|
  145. | | Filename of a binary on disk used to determine if the program | | | | |
  146. | TryExec | is actually installed. If not, entry may not show in menus, | string | NO | NO | 1 |
  147. | | etc. | | | | |
  148. |------------------------+----------------------------------------------------------------+--------------+------+-------+------|
  149. | Exec | Program to execute, possibly with arguments. | string | NO | YES | 1 |
  150. |------------------------+----------------------------------------------------------------+--------------+------+-------+------|
  151. | Path | If entry is type Application, the working directory to run the | string | NO | YES | 1 |
  152. | | program in. | | | | |
  153. |------------------------+----------------------------------------------------------------+--------------+------+-------+------|
  154. | Terminal | Whether the program runs in a terminal window | boolean | NO | YES | 1 |
  155. |------------------------+----------------------------------------------------------------+--------------+------+-------+------|
  156. | SwallowTitle | If entry is swallowed onto the panel, this should be the title | localestring | NO | NO | 1 |
  157. | | of window | | | | |
  158. |------------------------+----------------------------------------------------------------+--------------+------+-------+------|
  159. | SwallowExec | Program to exec if swallowed app is clicked. | string | NO | NO | 1 |
  160. |------------------------+----------------------------------------------------------------+--------------+------+-------+------|
  161. | Actions | Additional actions possible, see MIME type discussion in the | string(s) | NO | YES | 1 |
  162. | | section called "Detailed discussion of supporting MIME types". | | | | |
  163. |------------------------+----------------------------------------------------------------+--------------+------+-------+------|
  164. | MimeType | The MIME type(s) supported by this entry. | regexp(s) | NO | NO | 1 |
  165. |------------------------+----------------------------------------------------------------+--------------+------+-------+------|
  166. | SortOrder | This may specify the order in which to display files. | string(s) | NO | NO | 4 |
  167. |------------------------+----------------------------------------------------------------+--------------+------+-------+------|
  168. | Dev | The device to mount. | string | NO | NO | 3 |
  169. |------------------------+----------------------------------------------------------------+--------------+------+-------+------|
  170. | FSType | The type of filesystem to try to mount. | string | NO | NO | 3 |
  171. |------------------------+----------------------------------------------------------------+--------------+------+-------+------|
  172. | MountPoint | The mount point of the device in question. | string | NO | NO | 3 |
  173. |------------------------+----------------------------------------------------------------+--------------+------+-------+------|
  174. | ReadOnly | Specifies whether or not the device is read-only. | boolean | NO | NO | 3 |
  175. |------------------------+----------------------------------------------------------------+--------------+------+-------+------|
  176. | | Icon to display when device is not mounted Mounted devices | | | | |
  177. | UnmountIcon | display icon from Icon key. UnmountIcons may be localized with | string | NO | NO | 3 |
  178. | | the UnmountIcon[xx]= syntax. | | | | |
  179. |------------------------+----------------------------------------------------------------+--------------+------+-------+------|
  180. | URL | If entry is Link type, the URL to access. | string | NO | YES | 2 |
  181. |------------------------+----------------------------------------------------------------+--------------+------+-------+------|
  182. | Categories | Categories in which the entry should be shown in a menu (for | string(s) | NO | NO | 1 |
  183. | | possible values see the xdg-menu specification). | | | | |
  184. |------------------------+----------------------------------------------------------------+--------------+------+-------+------|
  185. | | A list of strings identifying the environments that should | | | | |
  186. | OnlyShowIn / NotShowIn | display/not display a given .desktop item. Only one of these | string(s) | NO | NO | 1-4 |
  187. | | keys, either OnlyShowIn or NotShowIn, may appear in a Group. | | | | |
  188. | | (for possible values see the xdg-menu specification) | | | | |
  189. |------------------------+----------------------------------------------------------------+--------------+------+-------+------|
  190. | | If true, it is KNOWN that the application will send a "remove" | | | | |
  191. | StartupNotify | message when started with the DESKTOP_LAUNCH_ID environment | boolean | NO | NO | 1 |
  192. | | variable set (see the startup notification spec for more | | | | |
  193. | | details). | | | | |
  194. |------------------------+----------------------------------------------------------------+--------------+------+-------+------|
  195. | | If true, it is KNOWN that the application will map at least | | | | |
  196. | StartupWMClass | one window with the given string as its WM class or WM name | string | NO | NO | 1 |
  197. | | hint (see the startup notification spec for more details). | | | | |
  198. +------------------------------------------------------------------------------------------------------------------------------+
  199. Character set encoding of the file
  200. Desktop entry files are encoded as lines of 8-bit characters separated by LF characters.
  201. o Key names must contain only the characters 'A-Za-z0-9-'
  202. o Group names may contain all ASCII characters except for control characters and '[' and ']'.
  203. o Values of type string may contain all ASCII characters except for control characters.
  204. o Values of type boolean must either be the string 'true' or 'false'.
  205. o Numeric values must be a valid floating point number as recognized by the %f specifier for scanf.
  206. Comment lines are uninterpreted and may contain any character (except for LF). However, using UTF-8 for comment lines that
  207. contain characters not in ASCII is encouraged.
  208. The encoding for values of type localestring is determined by the Encoding field.
  209. List of valid Exec parameter variables
  210. Each "Exec" field may take a number of arguments which will be expanded by the file manager or program launcher and passed to
  211. the program if necessary.
  212. Literal % characters must be escaped as %%, and adding new format characters is not allowed. It's a fatal error to have an Exec
  213. field with a format character not given in the spec (exception to this are the deprecated format characters which can be
  214. ignored, that is expanded to no parameters, by the implementation). Again for emphasis: nonstandard extensions are not allowed
  215. here - you must add an X-Foo-Exec field if you have nonstandard Exec lines.
  216. The escaping of the exec parameters is done in the way the mailcap specification describes. Take a look at RFC 1524 for more
  217. information.
  218. Recognized fields are as follows:
  219. +------------------------------------------------------------------------------------------------------------------------------+
  220. | | a single file name, even if multiple files are selected. The system reading the Desktop Entry should recognize that the |
  221. | | program in question cannot handle multiple file arguments, and it should should probably spawn and execute multiple |
  222. | %f | copies of a program for each selected file if the program is not able to handle additional file arguments. If files are |
  223. | | not on the local file system (i.e. HTTP or FTP locations), the files will be copied to the local file system and %f |
  224. | | will be expanded to point at the temporary file. Used for programs that do not understand URL syntax. |
  225. |----+-------------------------------------------------------------------------------------------------------------------------|
  226. | %F | a list of files. Use for apps that can open several local files at once. |
  227. |----+-------------------------------------------------------------------------------------------------------------------------|
  228. | %u | a single URL. |
  229. |----+-------------------------------------------------------------------------------------------------------------------------|
  230. | %U | a list of URLs. |
  231. |----+-------------------------------------------------------------------------------------------------------------------------|
  232. | %d | directory containing the file that would be passed in a %f field |
  233. |----+-------------------------------------------------------------------------------------------------------------------------|
  234. | %D | list of directories containing the files that would be passed in to a %F field |
  235. |----+-------------------------------------------------------------------------------------------------------------------------|
  236. | %n | a single filename (without path) |
  237. |----+-------------------------------------------------------------------------------------------------------------------------|
  238. | %N | a list of filenames (without path) |
  239. |----+-------------------------------------------------------------------------------------------------------------------------|
  240. | %i | the Icon field of the desktop entry expanded as two parameters, first "--icon" and then the contents of the Icon field |
  241. | | (should not expand as any prameters if the Icon field is empty or missing) |
  242. |----+-------------------------------------------------------------------------------------------------------------------------|
  243. | %c | the translated Name field associated with the desktop entry |
  244. |----+-------------------------------------------------------------------------------------------------------------------------|
  245. | %k | the location of the desktop file as either a uri (if for example gotten from the vfolder system) or a local filename or |
  246. | | empty if no location is known |
  247. |----+-------------------------------------------------------------------------------------------------------------------------|
  248. | %v | the name of the Device entry in the desktop file |
  249. +------------------------------------------------------------------------------------------------------------------------------+
  250. Detailed discussion of supporting MIME types
  251. It is in every desktop's best interest to have thorough support for mime types. The old /etc/mailcap and /etc/mime.types files
  252. are rather limited in scope and frankly, are outdated. Various desktop systems have come up with different ways of extending
  253. this original system, but none are compatible with each other. The Desktop Entry Standard hopes to be able to provide the
  254. beginnings of a solution to this problem.
  255. At a very basic level, the "Exec" key provides the default action to take when the program described by a desktop entry is used
  256. to open a document or data file. Usually this consists of some action along the lines of "kedit %f" or "ee %f". This is a good
  257. start, but it isn't as flexible as it can be.
  258. Let us first establish that a program which supports a MIME type or multiple mime types may be able to support multiple actions
  259. on those MIME types as well. The desktop entry may want to define additional actions in addition to the default. The toplevel
  260. "Exec" key describes the default action; Let us define this action to also be known as the "Open" action. Additional actions
  261. which might be possible include View, Edit, Play, etc. A further revision of this document will probably specify several
  262. "standard" actions in addition to the default "Open" action, but in all cases, the number of actions is arbitrary.
  263. Let us use a sound player as a simple example. Call it sp. The default Exec (Open) action for this program would likely look
  264. something like:
  265. Exec=sp %u
  266. However, imagine the sound player also supports editing of sound files in a graphical manner. We might wish to define an
  267. additional action which could accomodate this. Adding the action would be performed like this:
  268. Actions=Edit;
  269. [Desktop Action Edit]
  270. Exec=sp -edit %u
  271. As you can see, defining the action "edit" will enable an additional group of the name [Desktop Action actionname] to be read.
  272. This group can contain an additional Exec line, as well as possibly other information like a new Name, Comment, Icon, and Path.
  273. Thus right-clicking on a .wav file will show both the default "Open" action and this "Edit" action to both be displayed as
  274. choices in the context-menu. A left click (double or single, whichever the file manager implements) would cause the default
  275. action to take place. These are implementation-specific details which are up to the implementer, and are not enforced by this
  276. standard.
  277. If no DefaultApp is specified for a particular MIME type, any one of the programs registered which claim to be able to handle
  278. the MIME type may become the default handler. This behaviour is undefined and implementation-specific. KDE doesn't use a
  279. DefaultApp anymore, but assigns a Preference number to each program, so that the highest number is the one chosen for handling
  280. the MIME type.
  281. Extending the format
  282. If the standard is to be amended with a new {key,value} pair which should be applicable to all supporting parties, a group
  283. discussion will take place. This is the preferred method for introducing changes. If one particular party wishes to add a field
  284. for personal use, they should prefix the key with the string "X-PRODUCT", i.e. "X-NewDesktop-Foo", following the precedent set
  285. by other IETF and RFC standards.
  286. Alternatively, fields can be placed in their own group, where they may then have arbitrary key names. If this is the case, the
  287. group should follow the scheme outlined above, i.e. [X-PRODUCT GROUPNAME] or something similar. These steps will avoid namespace
  288. clashes between different yet similar environments.
  289. ----------------------------------------------------------------------------------------------------------------------------