4

I saw the following question, but I can't comment yet. So I decided to create a separate one.

I have both transmission and deluge installed. And I have no association for application/x-bittorrent mime type, based on contents of /usr/share/gnome/applications/defaults.list and ~/.local/share/applications/mimeapps.list. But it seems .torrent extension has association and it's transmission. That is when I double-click a .torrent file, transmission is opened. The same goes for when I open it in chromium.

The question is how come it is transmission? Why not deluge? Both have this mime type in their .desktop files. Are the associations stored somewhere else?

UPD

$ egrep bittorrent /usr/share/applications/mimeapps.list
egrep: /usr/share/applications/mimeapps.list: No such file or directory
$ egrep bittorrent /usr/share/applications/mimeinfo.cache
application/x-bittorrent=transmission-gtk.desktop;deluge.desktop;
$ egrep bittorrent /usr/share/applications/defaults.list

$ egrep bittorrent /home/yuri/.local/share/applications/mimeapps.list
$ egrep bittorrent /home/yuri/.local/share/applications/defaults.list
egrep: /home/yuri/.local/share/applications/defaults.list: No such file or directory

The default is transmission. Changing order in /usr/share/applications/mimeinfo.cache changes the default application. Probably one shouldn't rely on this behavior.

  • There are other places as well, such as ~/.gnome/share/apps. Different distros and different desktops do this slightly differently. freedesktop.org has a spec-of-sorts. You've found the two places typical for Ubuntu. If they're both empty, I would guess the system has to pick one, and has some deterministic way of doing that. ~/.local/.../mimeapps.list is Ubuntu's standard user-level override, and that's where AliNa's dialog stores its settings. – Salt Sep 28 '13 at 17:19
  • @Salt please change your comment into an answer. – AliN Sep 29 '13 at 15:09
2

There are two ways a MIME type and a .desktop file are associated.

Method 1

The first way is through *.list MIME config files (many exist on the system, see below). For example, a typical entry in ~/.local/share/applications/mimeapps.list might be:

[Default Applications]
application/x-bittorrent=transmission.desktop;deluge.desktop

This means that the preferred application is transmission, if it cannot be found, then the second choice is deluge.

Method 2

The second way is through the .desktop file itself. The application advertises which MIME types it can open. For example, in transmission-gtk.desktop, we have the following line

MimeType=application/x-bittorrent;x-scheme-handler/magnet;

which indicates that this program can handle those two MIME types.

Which Application To Use?

The association between MIME types and Applications is defined by the freedesktop.org standards. Here are the steps taken when determining which application (i.e. which .desktop file) to launch for a given MIME type.

Step 1: Look for an association in the MIME config files. The lookup order is as follows:

$XDG_CONFIG_HOME/$desktop-mimeapps.list    
$XDG_CONFIG_HOME/mimeapps.list    
$XDG_CONFIG_DIRS/$desktop-mimeapps.list    
$XDG_CONFIG_DIRS/mimeapps.list    
$XDG_DATA_HOME/applications/$desktop-mimeapps.list    
$XDG_DATA_HOME/applications/mimeapps.list    
$XDG_DATA_DIRS/applications/$desktop-mimeapps.list   
$XDG_DATA_DIRS/applications/mimeapps.list

Step 2: Once all levels have been checked, if no entry could be found, the implementations can pick any of the .desktop files associated with the MIME type, taking into account added and removed associations (which exist in the MIME config files).

Although you do not have any MIME config files, the reason that transmission is being used is because of Step 2 as defined by the standard. Check your transmission-gtk.desktop file to see whether it advertises its ability to open torrents.

I suggest reading the linked document for a full understanding.

| improve this answer | |
0

You can choose the default one in a file Properties > Open with [tab]; for example for a video file:

Open with

You can simply select your preferred app and set it as default.

You can also see the open with list when right-clicking on the file. Double-clicking opens it with the default one.

| improve this answer | |
  • It answers a different question: how to change file association? And I'm asking how to explain the behavior I'm experiencing? – x-yuri Sep 28 '13 at 16:16
  • Do you mean that when you right click on a .torrent file there’s no app suggestion to open with? And also you mean Transmission is not the default one? I got from your question that Transmission is your default app for torrent; because you mentioned double-clicking. Double click runs the default app. So I thought you could set Deluge as the default. – AliN Sep 29 '13 at 9:02
  • I know how to change file association. I don't know why it is as it is. Why transmission is the default application for .torrent files. Or more precisely, where this information is stored. Gotta check out other variants suggested by Salt. – x-yuri Sep 29 '13 at 14:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.