Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

An XDG Desktop Entry is a UTF-8 text file that tells Linux desktop environments about an application, link, or directory entry. Use it to add an application to menus, define its name and icon, pass files or URLs to it, or declare MIME types it can handle. It is a defined interoperability format—not a shell script or an unrestricted INI file.

Start with a valid application entry

For an application launcher, create a file ending in .desktop with a [Desktop Entry] group. Keys are case-sensitive, duplicate keys in a group are not allowed, and values must follow the specification’s syntax. A minimal example is:

[Desktop Entry]
Type=Application
Name=Example App
Comment=Open files with Example App
Exec=example-app %F
Icon=example-app
Terminal=false
Categories=Utility;

Replace example-app with a command available by name in the desktop environment’s PATH, or provide its executable path. The example’s %F field code allows the launcher to pass multiple selected files. If the application does not accept files, use an appropriate command without a file field code.

Use plain, unlocalized keys such as Name and Comment as the base values. Localized display strings can be added with locale-suffixed keys, for example Name[fr]=.... Boolean values are true or false. Multi-value fields use semicolons; a trailing semicolon is conventionally used in fields such as Categories. Escape a literal semicolon in a value as ;. See the freedesktop.org Desktop Entry Specification for the full grammar and recognized keys.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose the filename and installation location

Application entries use the .desktop extension. Give the file a stable, unique name; for application entries, the stem should be a valid D-Bus well-known name and conventionally uses a reverse-DNS identifier based on a domain controlled by the author, followed by an application name. The specification describes this naming scheme in its file-naming section.

Desktop environments find application entries in applications directories beneath XDG data directories. A desktop-file ID is derived from the file’s path relative to that directory: remove the applications/ prefix and replace remaining slashes with hyphens. If two files produce the same ID, the first one in $XDG_DATA_DIRS precedence takes priority. Avoid path layouts that create colliding IDs rather than relying on an ambiguous selection.

Use .directory for entries with Type=Directory; other entry types conventionally use .desktop. The specification’s current file-naming guidance is available at the linked standard.

Set the fields that control how it appears

The main group can include recognized metadata for display, visibility, execution, and integration. These fields are useful starting points:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Type=Application identifies an application entry.
  • Name supplies the displayed name; GenericName and Comment can add a category-like label and description.
  • Icon identifies an icon by name or path. It is metadata for the desktop environment, not a guarantee that a particular theme or icon file will be available.
  • Categories can influence menu placement, while Keywords can make an entry searchable. Their effect depends on the desktop implementation.
  • NoDisplay=true hides an entry from menus while leaving it available to other mechanisms; Hidden=true marks it as deleted. OnlyShowIn and NotShowIn can restrict visibility by desktop environment.
  • TryExec lets a desktop environment check whether a program exists and is executable; if that check fails, the entry may be ignored.
  • Terminal=true requests execution in a terminal. Use it when the application needs an interactive terminal, not merely because it is a command-line program.

Optional keys are not uniformly supported. Avoid assuming every desktop environment implements every recognized hint in the same way.

Write Exec as a desktop-entry command line

Exec is not a shell command string. The executable is either a path or a name resolved through the desktop environment’s PATH; arguments are separated by spaces. Reserved characters in arguments require double-quoting and the escaping defined by the specification. Shell features such as pipes, redirects, variable expansion, and command substitution are not implied. If a launcher needs shell logic, use a dedicated executable or script as the program and pass it valid arguments.

Field codes let the desktop environment supply data when launching. The commonly useful codes are:

  • %f and %F pass a single file or multiple files.
  • %u and %U pass a single URL or multiple URLs.
  • %c expands to the translated application name.
  • %k expands to the desktop-file location.
  • %i expands to the icon option.

Use at most one of %f, %F, %u, or %U in an entry. %F and %U must each be a standalone argument, and field codes must not appear inside quoted arguments. Do not use deprecated field codes such as %m, %v, %d, %D, %n, or %N.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Handle files, URLs, and MIME types deliberately

Choose a file or URL field code only if the application can receive and open that kind of input. For example, an application that opens multiple local documents can use Exec=example-app %F; one that accepts URLs can use Exec=example-app %U. The field code governs what is passed at launch—it does not itself register a URL scheme or create an association.

MimeType lists the MIME types the application can handle, typically as a semicolon-separated value such as MimeType=text/plain;application/pdf;. The desktop file declares supported types but does not determine which application has priority for a type; association priority is managed elsewhere by the desktop environment. Ensure the command in Exec can actually open the declared types.

Use D-Bus activation only when the application implements it

DBusActivatable=true indicates that the application can be activated through D-Bus. The flag alone does not create the service: the application must implement the specified org.freedesktop.Application interface at the object path derived from its well-known name. Exec is required unless D-Bus activation is enabled, but retaining a valid Exec is recommended for compatibility with older implementations.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Add optional launcher actions

Actions define extra invocation paths, such as a quicklist item. List action identifiers in the main group’s Actions key and create a matching group for each one. For example:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
[Desktop Entry]
Type=Application
Name=Example App
Exec=example-app
Icon=example-app
Actions=NewWindow;

[Desktop Action NewWindow]
Name=New Window
Exec=example-app --new-window

An action not named in Actions is invalid and should be ignored. Some implementations do not support actions; in that case, the launcher can still use the main entry’s name, icon, and execution metadata.

Keep the file interoperable

Use UTF-8, exact key spelling, and one instance of each key per group. The specification says: “Compliant implementations MUST not remove any fields from the file, even if they don’t support them.” That preservation rule helps keep metadata available when a desktop environment does not recognize a field.

For new entries, avoid obsolete constructs including Type=MimeType, Encoding, [KDE Desktop Entry], and .kdelnk, as well as deprecated keys such as MiniIcon, TerminalOptions, Protocols, Extensions, BinaryPattern, MapNotify, and SortOrder. Optional keys and implementation support can change, so consult the current specification and your target desktop environment’s documentation for version-specific behavior.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.