Difference between revisions of "Xdg-open"

From ArchWiki
Jump to: navigation, search
(Merge Environment Variables to Environment Variables)
m
Line 2: Line 2:
 
{{i18n|xdg-open}}
 
{{i18n|xdg-open}}
  
xdg-open is a desktop-independent tool for configuring the default applications of a user. Many applications invoke the {{Codeline|xdg-open}} command internally.
+
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.
 
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==
+
== Installation ==
xdg-open is part of the {{pkg|xdg-utils}} package available in extra:
+
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.
  
pacman -S xdg-utils
+
== Configuration ==
 
+
=== The config file ===
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}} use configuration files located at {{ic|~/.local/share/applications/defaults.list}}(for a single user) and {{ic|/usr/share/applications/defaults.list}} (system wide). Its format is as follows:
 
{{ic|xdg-open}} use configuration files located at {{ic|~/.local/share/applications/defaults.list}}(for a single user) and {{ic|/usr/share/applications/defaults.list}} (system wide). Its format is as follows:
 
  [Default Applications]
 
  [Default Applications]
Line 31: Line 26:
 
To make Thunar the default file-browser, i.e. the default application for opening folders.
 
To make Thunar the default file-browser, i.e. the default application for opening folders.
  
  xdg-mime default Thunar.desktop inode/directory
+
  $ xdg-mime default Thunar.desktop inode/directory
  
 
to use {{pkg|xpdf}} as the default PDF viewer:
 
to use {{pkg|xpdf}} as the default PDF viewer:
Line 52: Line 47:
 
{{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}} or {{ic|~/.config/mimeo.conf}}
 
{{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}} or {{ic|~/.config/mimeo.conf}}
  
===Environment Variables===
+
=== 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.
 
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==
+
== See also ==
 
 
 
* [[Default Applications]] - desktop-specific instructions/overview of alternatives to xdg-open
 
* [[Default Applications]] - desktop-specific instructions/overview of alternatives to xdg-open
 
* [[Environment Variables]]
 
* [[Environment Variables]]

Revision as of 05:39, 23 January 2012

This template has only maintenance purposes. For linking to local translations please use interlanguage links, see Help:i18n#Interlanguage links.


Local languages: Català – Dansk – English – Español – Esperanto – Hrvatski – Indonesia – Italiano – Lietuviškai – Magyar – Nederlands – Norsk Bokmål – Polski – Português – Slovenský – Česky – Ελληνικά – Български – Русский – Српски – Українська – עברית – العربية – ไทย – 日本語 – 正體中文 – 简体中文 – 한국어


External languages (all articles in these languages should be moved to the external wiki): Deutsch – Français – Română – Suomi – Svenska – Tiếng Việt – Türkçe – فارسی

xdg-open is a desktop-independent tool for configuring the default applications of a user. Many applications invoke the xdg-open command internally.

Inside a desktop environment (e.g. GNOME, KDE, Xfce, etc.), xdg-open simply passes the arguments to that desktop environment's file-opener application (gvfs-open, kde-open, or 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, e.g. Openbox), xdg-open will use its own configuration files.

Installation

xdg-open is part of the 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

xdg-open use configuration files located at ~/.local/share/applications/defaults.list(for a single user) and /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 MimeTypes list in your application's .desktop file.

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 xpdf as the default PDF viewer:

$ xdg-mime default xpdf.desktop application/pdf

This should create an entry in your local MIME database:

~/.local/share/applications/defaults.list
[Default Applications]
application/pdf=xpdf.desktop

Your PDF files should be opened with xpdf now.

mimetype

mimetype in perl-file-mimeinfo package is more intuitive.

To select default application for a given extension (you need a sample file):

$ mimetype -d file.extension

mimeo

mimeoAUR and xdg-utils-mimeoAUR in AUR provide xdg-utils and contains a xdg-open script patched to make use of mimeo the same way gnome-open would be used. Mimetype<->application associations can then be customised easily in $XDG_CONFIG_HOME/mimeo.conf or ~/.config/mimeo.conf

Environment Variables

Some environment variables such as BROWSER, DE and DESKTOP_SESSION will change behaviour of xdg-open. See Environment Variables for more information.

See also