mbeijen / File-MimeInfo

Perl module for determining file types using the freedesktop.org shared mime-info database
https://metacpan.org/module/File::MimeInfo
20 stars 13 forks source link

_default returns incorrect application when multiple mimeapps.list files are present #37

Open p-himik opened 5 years ago

p-himik commented 5 years ago

Full disclosure: I'm not a Perl developer, so I can make wrong assumptions here. Observed behavior: after setting a default app with mimeopen -d %file%, using mimeopen %file% uses the old app and not the new default.

There are these lines: https://github.com/mbeijen/File-MimeInfo/blob/master/lib/File/MimeInfo/Applications.pm#L103-L105 Now, the user's mimeapps.list goes first there, and that's how it's supposed to be. But then, the list is reversed for some reason. Hence, _find_file always receives the old apps first.

martintxoz commented 4 years ago

I don't know to code anything too. But I find this too useful for me to see why mimeopen was failing...

My problem was: I need to make a new association for open a rar file with engrampa. I don't use a Desktop Environment, but need to associate this for opening rar files from de web browser...

I made this association with mimeopen and works (opening it with xdg-open). But I can't see it if I open it latter with mimeopen only to see what is the defaul app. And the same is if I try to open it with 'mimeopen -n', it try to open the rar file with de Atril pdf viewer!! (the old default), while xdg-open opens it with the new default: engrampa.

If I edit the file /usr/share/perl5/File/MimeInfo/Applications.pm (this is Debian Testing with the default libfile-mimeinfo-perl package), if in the line 105 I delete the 'reverse ' word, now mimeopen is working fine. See the output of mimeopen -d:

use application #


- With this change:

$ mimeopen -D -d Informes.rar

Data dirs are: /home/martintxo/.local/share, /usr/local/share, /usr/share Checking inode type Checking globs for basename 'Informes.rar' Checking for extension '.rar' Please choose a default application for files of type application/vnd.rar

1) engrampa  (engrampa-usercreated-1)
2) Xarchiver  (xarchiver)
3) Leafpad  (leafpad)
4) Other...

use application #



So I think that it is a bug, and to solve it is needed to edit this lines in Applications.pm. 

Thank you in advance. Greetings. Martintxo.