arrow_back
Back

Linux default apps: URI handlers, xdg-mime, and MIME types

Andrew Dorokhov Andrew Dorokhov schedule 1 min read
menu_book Table of Contents

We can see the whole list of MIME-types and corresponding applications in the following file:

/usr/share/applications/defaults.list

Rows related to URI scheme are beginning with x-scheme-handler. Examples:

x-scheme-handler/http=firefox.desktop;google-chrome.desktop
x-scheme-handler/https=firefox.desktop;google-chrome.desktop
x-scheme-handler/apt=apturl.desktop
x-scheme-handler/mailto=thunderbird.desktop
x-scheme-handler/snap=snap-store_ubuntu-software.desktop

Desktop entry file

In Ubuntu and other Linux-based systems, a desktop entry file is a text-based configuration file with a .desktop extension. It provides information about an application, such as its name, icon, command to execute, and other metadata. Desktop entry files are used to integrate applications into the desktop environment and provide a consistent way to launch and manage applications.

Here are some of the common fields found in a desktop entry file:

  • Name: The display name of the application.
  • Exec: The command to execute the application.
  • Icon: The path to the icon file for the application.
  • Type: The type of the application (e.g., Application, Link, Directory).
  • Categories: The categories or groups under which the application should be listed.
  • MimeType: The supported MIME types by the application.
  • Terminal: Specifies whether the application should run in a terminal window.
  • StartupNotify: Specifies whether the application should send startup notification.

Desktop Entry File:

[Desktop Entry]
Name=Profile
Type=Application
Exec=google-chrome %u
MimeType=x-scheme-handler/profile;

Add the profile.desktop file to:

  • ~/.local/share/applications/ (user-wide)
  • /usr/share/applications/ (system-wide).

Register MIME-type:

xdg-mime default profile.desktop x-scheme-handler/profile

Testing

xdg-open profile://hello
code

Need Help with Development?

Happy to help — reach out via the contacts or go straight to my Upwork profile.

work View Upwork Profile arrow_forward
Next Article

cURL command-line: HTTP, downloads, headers, and authentication

arrow_forward