Difference between revisions of "Xdg-open"

From ArchWiki
Jump to: navigation, search
m (See also)
(Configuration: Merge in xdg-open configuration info from artical Chromium)
Line 12: Line 12:
  
 
==Configuration==
 
==Configuration==
You can bind mimetypes to .desktop files in {{filename|/usr/share/applications}} and {{filename|~/.local/share/applications}} with the xdg-mime command:
 
 
# This will make Thunar the default file-browser, i.e. the default application for opening folders.
 
xdg-mime default Thunar.desktop inode/directory
 
 
The best way to look up the MIME type is to read the {{Codeline|MimeTypes}} list in your application's {{filename|.desktop}} file.
 
  
 
===The config file===
 
===The config file===
{{Codeline|xdg-mime}} saves the configuration for {{Codeline|xdg-open}} in {{filename|~/.local/share/applications/defaults.list}}. 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]
 
  mimetype=desktopfile1;desktopfile2...
 
  mimetype=desktopfile1;desktopfile2...
Line 28: Line 22:
 
  inode/directory=kde4-dolphin.desktop;Thunar.desktop;nautilus.desktop
 
  inode/directory=kde4-dolphin.desktop;Thunar.desktop;nautilus.desktop
  
It seems that it is perfectly save to edit that file.
+
The best way to look up the MIME type is to read the {{ic|MimeTypes}} list in your application's {{ic|.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 {{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.
 +
 
 +
=== mimetype  ===
 +
mimetype in {{pkg|perl-file-mimeinfo}} package is more intuitive.
 +
 
 +
To select default application for a given extension (you need a sample file):
 +
$ mimetype -d file.extension
  
If you want to set your default applications system-wide, copy this file to {{filename|/usr/share/applications}}
+
For me it only worked as normal user - as root I had problems because no directories for the local MIME times were created. See also [https://bbs.archlinux.org/viewtopic.php?id=93956 this thread].
  
 
===Environment Variables===
 
===Environment Variables===

Revision as of 05:25, 9 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 – فارسی

Tango-view-fullscreen.pngThis article or section needs expansion.Tango-view-fullscreen.png

Reason: please use the first argument of the template to provide a brief explanation. (Discuss in Talk:Xdg-open#)

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

Installation

xdg-open is part of the xdg-utils package available in extra:

pacman -S xdg-utils

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

For me it only worked as normal user - as root I had problems because no directories for the local MIME times were created. See also this thread.

Environment Variables

export BROWSER=chromium # this will make xdg-open use chromium for any kind of URLs
export DE="xfce" # This will make xdg-open use the more user-friendly exo-open, because it assumes it is inside Xfce. Use exo-preferred-applications for configuring.

See also