Difference between revisions of "Default applications"

From ArchWiki
Jump to: navigation, search
m
Line 11: Line 11:
 
==Changing a default application ==
 
==Changing a default application ==
 
===xdg-open===
 
===xdg-open===
The {{Codeline|xdg-open}} command uses the {{filename|~/.local/share/applications/mimeapps.list}} file to pick which application to use. Many applications invoke this command internally, so this may be the best place to look. Its contents refer to the {{filename|.desktop}} files located in /usr/share/applications/. KDE applications are located in the {{filename|kde4}} subdirectory and are referred to by prefixing {{filename|kde4-}} to the {{filename|.desktop}} file's name (e.g. {{filename|kde4-dolphin.desktop}}).
+
Many applications invoke the {{Codeline|xdg-open}} command internally.
  
{{filename|mimeapps.list}} lists applications in order of preference; if the first listed application is not installed, the second one will be used. Its format is as follows:
+
You can bind mimetypes to .desktop files in {{filename|/usr/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.
 +
You can put custom {{filename|.desktop}} files into {{filename|~/.local/share/applications}}.
 +
 
 +
====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:
 
  [Default Applications]
 
  [Default Applications]
 
  mimetype=desktopfile1;desktopfile2...
 
  mimetype=desktopfile1;desktopfile2...
Line 22: Line 30:
 
  inode/directory=kde4-dolphin.desktop;Thunar.desktop;nautilus.desktop
 
  inode/directory=kde4-dolphin.desktop;Thunar.desktop;nautilus.desktop
  
The best way to look up the MIME type is to read the {{Codeline|MimeTypes}} list in your application's {{filename|.desktop}} file.
+
You shouldn't mess with that file and use the {{Codeline|xdg-mime}} command instead.
 
+
You shouldn't mess with the {{Codeline|[Added Associations]}} section, but see [[#Exactly how the config files mesh together|Exactly how the config files mesh together]] if you do. There is also a {{filename|/usr/share/applications/mimeapps.list}} that doesn't exist on Arch by default which you also probably shouldn't mess with.
+
 
+
You can put custom {{filename|.desktop}} files into {{filename|~/.local/share/applications}}.
+
  
 
===Gnome 3===
 
===Gnome 3===
====xdg-open====
+
The xdg-open settings are usually recognized by Gnome, but if they aren't, there are still other methods.
The file {{filename|~/.local/share/applications/defaults.list}} has the same syntax as {{filename|mimeapps.list}}. You can use it instead of {{filename|mimeapps.list}}, but it's probably best to use {{filename|mimeapps.list}}; see [[#Exactly how the config files mesh together|Exactly how the config files mesh together]].
+
 
+
Sometimes, a certain application will not appear in the right-click ''Open With...'' dialog. To fix this problem, locate the {{filename|.desktop}} file in {{filename|/usr/share/applications}}, edit it as root, and add {{Codeline|%U}} to the end of the {{Codeline|1=<nowiki>Exec=</nowiki>}} line. For example, Kile currently has this problem; you need to edit {{filename|/usr/share/applications/kde4/kile.desktop}} and change the line reading {{Codeline|1=<nowiki>Exec=kile</nowiki>}} to read {{Codeline|1=<nowiki>Exec=kile %U</nowiki>}}. Also, please file a bug against the upstream project if you notice this problem.
+
 
+
You may also have to edit the {{Codeline|MimeTypes}} list in the {{filename|.desktop}} file if you install extensions that allow an application to handle additional MIME types.
+
  
 
====GConf====
 
====GConf====
Line 51: Line 50:
  
 
====Exactly how the config files mesh together====
 
====Exactly how the config files mesh together====
This is not necessary reading, but here is, as nearly as I can tell, the precedence order for the various config files, from high to low:
+
This is not necessary reading, but here is, as nearly as I can tell, xdg-open looks for the following sections in the following files.
 
  ~/.local/share/applications/mimeapps.list, [Default Applications] section
 
  ~/.local/share/applications/mimeapps.list, [Default Applications] section
 
  ~/.local/share/applications/mimeapps.list, [Added Applications] section
 
  ~/.local/share/applications/mimeapps.list, [Added Applications] section
Line 62: Line 61:
 
See also [http://www.freedesktop.org/wiki/Specifications/mime-actions-spec this page on freedesktop.org], "Default application ordering" section.
 
See also [http://www.freedesktop.org/wiki/Specifications/mime-actions-spec this page on freedesktop.org], "Default application ordering" section.
  
===Without desktop environment - make xdg-open a wrapper for exo-open===
+
===make xdg-open a wrapper for exo-open===
  
 
You might want to make xdg-open a wrapper for exo-open from Xfce, because exo-open tends to be more user-friendly to configure outside a desktop-environment. To do so, make sure that your configuration under .local/share/applications is gone (all those .list files) and insert the following somewhere in your .xinitrc:
 
You might want to make xdg-open a wrapper for exo-open from Xfce, because exo-open tends to be more user-friendly to configure outside a desktop-environment. To do so, make sure that your configuration under .local/share/applications is gone (all those .list files) and insert the following somewhere in your .xinitrc:
Line 76: Line 75:
 
==Maintaining settings for multiple desktop environments==
 
==Maintaining settings for multiple desktop environments==
 
More info later...
 
More info later...
 +
 +
==Troubleshooting==
 +
===Applications don't appear in the ''Open With...'' context menu (of a file manager)===
 +
Sometimes, a certain application will not appear in the right-click ''Open With...'' dialog. To fix this problem, locate the {{filename|.desktop}} file in {{filename|/usr/share/applications}}, edit it as root, and add {{Codeline|%U}} to the end of the {{Codeline|1=<nowiki>Exec=</nowiki>}} line. For example, Kile currently has this problem; you need to edit {{filename|/usr/share/applications/kde4/kile.desktop}} and change the line reading {{Codeline|1=<nowiki>Exec=kile</nowiki>}} to read {{Codeline|1=<nowiki>Exec=kile %U</nowiki>}}. Also, please file a bug against the upstream project if you notice this problem.
 +
 +
You may also have to edit the {{Codeline|MimeTypes}} list in the {{filename|.desktop}} file if you install extensions that allow an application to handle additional MIME types.

Revision as of 15:10, 7 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-document-new.pngThis article is a stub.Tango-document-new.png

Notes: please use the first argument of the template to provide more detailed indications. (Discuss in Talk:Default applications#)

There are numerous places to configure default applications on Linux. This page will attempt to address problems related to the following issues:

  • You need to change a certain default application (e.g. after switching desktop environments), but there appears to be nowhere to configure it, or an application ignores your configuration
  • You regularly switch back and forth between several desktop environments, and need to configure some applications (e.g. file manager) on a per-desktop-environment basis, but need to configure others (e.g. web browser) globally

Until there is more information/organization, it will just be a dumping ground of random tricks

Changing a default application

xdg-open

Many applications invoke the Template:Codeline command internally.

You can bind mimetypes to .desktop files in Template:Filename 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 Template:Codeline list in your application's Template:Filename file. You can put custom Template:Filename files into Template:Filename.

The config file

Template:Codeline saves the configuration for Template:Codeline in Template:Filename. 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

You shouldn't mess with that file and use the Template:Codeline command instead.

Gnome 3

The xdg-open settings are usually recognized by Gnome, but if they aren't, there are still other methods.

GConf

As far as I can tell, on Gnome 3, there are two configuration systems, GConf (older) and dconf (newer). GConf can be configured with Template:Codeline; in particular, you can try messing with the Template:Filename key, but changing settings there didn't fix any problems I had. dconf can be configured with the Template:Codeline command.

Terminal

To configure the default terminal for the package nautilus-open-terminal to Konsole, use

$ gsettings set org.gnome.desktop.default-applications.terminal exec konsole
$ gsettings set org.gnome.desktop.default-applications.terminal exec-arg "'-e'"

The second command tells Template:Codeline to expect a command to be passed to it as part of the invocation. nautilus-open-terminal needs this because it passes a Template:Codeline command in order to switch to the appropriate directory. For example, opening a terminal in your Template:Filename directory will invoke something like

$ konsole -e cd "~/Desktop"

Web browser

To configure the web browser used by the AUR package gnome-gmail-notifier, run

$ gconf-editor

and edit the Template:Filename key. You may want to change Template:Filename, Template:Filename, and Template:Filename keys while you're at it.

Exactly how the config files mesh together

This is not necessary reading, but here is, as nearly as I can tell, xdg-open looks for the following sections in the following files.

~/.local/share/applications/mimeapps.list, [Default Applications] section
~/.local/share/applications/mimeapps.list, [Added Applications] section
~/.local/share/applications/defaults.list
/usr/share/applications/mimeapps.list, [Default Applications] section
/usr/share/applications/mimeapps.list, [Added Applications] section
/usr/share/applications/defaults.list

Note that ordinarily, if a higher-precedence config file (or config file section) specifies an application that is not installed, it will fall-back to a lower-precedence config file (or section). However, if a non-existent application is specified in any Template:Filename file, then all of the Template:Filename files will be ignored for that MIME type.

See also this page on freedesktop.org, "Default application ordering" section.

make xdg-open a wrapper for exo-open

You might want to make xdg-open a wrapper for exo-open from Xfce, because exo-open tends to be more user-friendly to configure outside a desktop-environment. To do so, make sure that your configuration under .local/share/applications is gone (all those .list files) and insert the following somewhere in your .xinitrc:

export DE="xfce"

This will make xdg-open use exo-open, because it assumes it is inside Xfce.

To set your default applications in exo-open, launch the GTK GUI with

exo-preferred-applications

Maintaining settings for multiple desktop environments

More info later...

Troubleshooting

Applications don't appear in the Open With... context menu (of a file manager)

Sometimes, a certain application will not appear in the right-click Open With... dialog. To fix this problem, locate the Template:Filename file in Template:Filename, edit it as root, and add Template:Codeline to the end of the Template:Codeline line. For example, Kile currently has this problem; you need to edit Template:Filename and change the line reading Template:Codeline to read Template:Codeline. Also, please file a bug against the upstream project if you notice this problem.

You may also have to edit the Template:Codeline list in the Template:Filename file if you install extensions that allow an application to handle additional MIME types.