Default applications

From ArchWiki
Jump to navigation Jump to search


Reason: Add more applications to the table. Do KDE applications use QDesktopServices::openUrl? Mention exo-open(1). (Discuss in Talk:Default applications#)

Programs implement default application associations in different ways, while command-line programs traditionally use environment variables, graphical applications tend to use XDG MIME Applications through either the GIO API, the Qt API or by executing /usr/bin/xdg-open, which is part of xdg-utils. Because xdg-open and XDG MIME Applications are quite complex various alternative resource openers were developed. These alternatives replace /usr/bin/xdg-open, which obviously only affects applications that actually use the executable. The following table lists some example applications for each method.

Method Uses XDG Application examples
GIO's GAppInfo Yes Firefox, GNOME Files, PCManFM, Thunar, Thunderbird
/usr/bin/xdg-open By default Chromium
custom Usually not mc, ranger
environment variables No man, sudoedit, systemctl

Many desktop environments and graphical file managers provide a GUI for configuring default applications.

Background information

Programs sometimes need to open a file or a URI in the user's preferred application. To open a file in the user's preferred application the filetype needs to be detected (usually using filename extensions or magic numbers mapped to MIME types) and there needs to be an application associated with the filetype.

Heirloom UNIX programs used mime.types for MIME type detection and mailcap for application association.

Resource openers

  • XDG MIME Apps: implements the XDG MIME Applications specification
  • RegEx rules: allows MIME types to be associated with applications using regular expressions
  • URI support: allows arbitrary URI schemes to be associated with applications
Name Package XDG MIME Apps RegEx rules URI support
xdg-open xdg-utils Yes No Yes
mimeopen(1p) perl-file-mimeinfo Yes No No
mimeo mimeoAUR Yes Yes Yes
whippet whippetAUR Yes No Yes
linopen linopenAUR No Yes Yes
mimi mimi-gitAUR No No partly
busking busking-gitAUR No Yes Yes
sx-open sx-openAUR No Yes Yes
rifle(1) ranger No Yes No


xdg-open (part of xdg-utils) implements XDG MIME Applications and is used by many programs.

Because of the complexity of the xdg-utils version of xdg-open, it can be difficult to debug when the wrong default application is being opened. Because of this, there are many alternatives that attempt to improve upon it. Several of these alternatives replace the /usr/bin/xdg-open executable, thus changing the default application behavior of most applications. Others simply provide an alternative method of choosing default applications.


perl-file-mimeinfo provides the tools mimeopen(1p) and mimetype(1p). These have a slightly nicer interface than their xdg-utils equivalents:

# determine a file's MIME type
$ mimetype photo.jpeg
photo.jpeg: image/jpeg

# choose the default application for this file
$ mimeopen -d photo.jpeg
Please choose an application

    1) Feh (feh)
    2) GNU Image Manipulation Program (gimp)
    3) Pinta (pinta)

use application #

# open a file with its default application
$ mimeopen -n photo.jpeg

Most importantly, xdg-utils programs will actually call mimetype instead of file for MIME type detection, if it does not detect your desktop environment. This is important because file does not follow the XDG standard.

Note: perl-file-mimeinfo before 0.28-1 does not entirely follow the XDG standard. For example it does not read distribution-wide defaults and it saves its config in deprecated locations.



# determine a file's MIME type
$ mimeo -m photo.jpeg

# choose the default application for this MIME type
$ mimeo --add image/jpeg feh.desktop

# open a file with its default application
$ mimeo photo.jpeg


# open youtube links in VLC without opening a new instance




# open a file with its default application
$ whippet -M photo.jpeg

$ whippet -m photo.jpeg

In addition to implementing XDG MIME Applications, whippet can also use a SQlite database of weighted application/MIME type/regex associations to determine which app to use.

Minimalist replacements

The following packages conflict with and provide xdg-utils because they provide their own /usr/bin/xdg-open script.

If you want to use one of these resource openers while still being able to use xdg-utils, install them manually in a PATH directory before /usr/bin.

  • linopenAUR - 170-line Bash script, supports regex rules
  • mimi-gitAUR - 130-line Bash script, can change command arguments for each MIME type
  • busking-gitAUR - 80-line Perl script similar to mimi but also supports regex rules
  • sx-openAUR - 60-line Bash script, uses a simple shell-based config file


Warning: If you use run-mailcapAUR, it is possible for xdg-open to delegate to it. This will cause an infinite loop if you are using the /etc/mailcap from mailcap, because it also delegates to xdg-open.