Difference between revisions of "Xdg-open"

From ArchWiki
Jump to: navigation, search
(run-mailcap)
(added: "#REDIRECT Default applications")
 
(127 intermediate revisions by 33 users not shown)
Line 1: Line 1:
[[Category:Desktop environments]]
+
#REDIRECT [[Default applications]]
xdg-open is a desktop-independent tool for configuring the default applications of a user. Many applications invoke the {{Ic|xdg-open}} command internally.
+
 
+
Inside a [[Desktop Environment|desktop environment]] (e.g. [[GNOME]], [[KDE]], [[Xfce]], etc.), {{ic|xdg-open}} simply passes the arguments to that desktop environment's file-opener application ({{ic|gvfs-open}}, {{ic|kde-open}}, or {{ic|exo-open}}, respectively), which means that the associations are left up to the desktop environment. When no desktop environment is detected (for example when one runs a standalone [[Window Manager|window manager]], e.g. [[Openbox]]), {{ic|xdg-open}} will use its own configuration files.
+
 
+
== Installation ==
+
xdg-open is part of the {{pkg|xdg-utils}} package available in [extra]. xdg-open is for use inside a desktop session only. It is not recommended to use xdg-open as root.
+
 
+
== Configuration ==
+
=== The config file ===
+
{{ic|xdg-open}} uses configuration files located at {{ic|$XDG_DATA_HOME/applications/mimeapps.list}} (for a single user; {{ic|$XDG_DATA_HOME}} defaults to {{ic|~/.local/share}}) and {{ic|/usr/share/applications/defaults.list}} (system wide). Its format is as follows:
+
[Default Applications]
+
mimetype=desktopfile1;desktopfile2...
+
For example,
+
[Default Applications]
+
text/html=firefox.desktop
+
inode/directory=kde4-dolphin.desktop;Thunar.desktop;nautilus.desktop
+
 
+
The best way to look up the MIME type is to read the {{ic|MimeTypes}} list in your application's {{ic|.desktop}} file (see [[Desktop Entries]] for details).
+
 
+
Some tools are available to edit the configuration files:
+
 
+
=== xdg-mime ===
+
To make Thunar the default file-browser, i.e. the default application for opening folders.
+
 
+
$ xdg-mime default Thunar.desktop inode/directory
+
 
+
to use {{pkg|xpdf}} as the default PDF viewer:
+
$ xdg-mime default xpdf.desktop application/pdf
+
 
+
This should create an entry in your local MIME database:
+
{{hc|~/.local/share/applications/defaults.list|<nowiki>
+
[Default Applications]
+
application/pdf=xpdf.desktop
+
</nowiki>}}
+
Your PDF files should be opened with {{pkg|xpdf}} now.
+
 
+
==Drop-in replacements and useful tools==
+
 
+
===run-mailcap===
+
The {{ic|.mailcap}} file format used by the mutt mail program is way easier to read and write. The {{AUR|run-mailcap}} package from the AUR provides a executable that could be easily symlinked to {{ic|/usr/bin/xdg-open}}, but that parser is unable to handle directories or links. The simplest solution would be to install mimeo from the AUR too and create a {{ic|/usr/bin/xdg-open}} with the following content:
+
 
+
  #!/bin/sh
+
  run-mailcap $1 || mimeo $1
+
 
+
Then use the {{ic|defaults.list}} at {{ic|~/.local/share/applications/}} to associate URLs and folders with applications and the {{ic|.mailcap}} file for normal mimetypes.
+
 
+
=== mimetype  ===
+
mimetype in {{pkg|perl-file-mimeinfo}} package can display some mimetype-related information about a file.
+
 
+
For example:
+
 
+
$ mimetype file.ext
+
 
+
returns the mimetype of a file,
+
 
+
$ mimetype -d file.extension
+
 
+
returns a description of that mimetype.
+
 
+
=== mimeo ===
+
{{AUR|mimeo}} and {{AUR|xdg-utils-mimeo}} in [[Arch User Repository|AUR]] provide {{pkg|xdg-utils}} and contains a {{ic|xdg-open}} script patched to make use of {{ic|mimeo}} the same way {{ic|gnome-open}} would be used. Mimetype<->application associations can then be customised easily in {{ic|$XDG_CONFIG_HOME/mimeo.conf}} (i.e.{{ic|~/.config/mimeo.conf}})
+
 
+
=== Environment Variables ===
+
Some environment variables such as {{ic|BROWSER}}, {{ic|DE}} and {{ic|DESKTOP_SESSION}} will change behaviour of xdg-open. See [[Environment Variables]] for more information.
+
 
+
== See also ==
+
* [[Default Applications]] - desktop-specific instructions/overview of alternatives to xdg-open
+
* [[Environment Variables]]
+

Latest revision as of 14:24, 22 May 2016