You are not logged in.

#1 2012-06-02 00:39:17

ninian
Member
From: United Kingdom
Registered: 2008-02-24
Posts: 726
Website

[solved] XDG_DATA_DIRS: Why is order of paths non-standard?

As far as I can gather, $XDG_DATA_DIRS is set by /etc/profile.d/xorg.sh, but for some reason it orders the paths thus:

export XDG_DATA_DIRS=/usr/share/:/usr/local/share/

which goes against the recommendation at http://standards.freedesktop.org/basedi … atest.html which states:

If $XDG_DATA_DIRS is either not set or empty, a value equal to /usr/local/share/:/usr/share/ should be used.

This seems to be causing me a problem with Xyne's mimeo package, when I put my default associations in /usr/local/share/applications/mimeapps.list (in [Added Associations] section; I have no defaults.list files anywhere). Mimeo does not pick up these defaults with the default Arch path ordering for XDG_DATA_DIRS, but if I reverse the ordering to be as recommended by freedesktop.org, mimeo seems to work as expected.
Is there a good reason for the Arch ordering, and if so, should mimeo not be coping with it?
Something's not right somewhere with this!
hmm

Edited: typo corrected: spelling of [Added Associations]

Last edited by ninian (2012-06-03 09:25:15)

Offline

#2 2012-06-02 14:33:01

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,963
Website

Re: [solved] XDG_DATA_DIRS: Why is order of paths non-standard?

File a bug report for. The default path is set by /etc/profile.d/xorg.sh, which belongs to the libx11 package.

Mimeo cannot possibly know if the order of the environment variable is "wrong". It respects the XDG standards and loads files such that those that occur first in the path take precedence.

The only possibly bug with Mimeo here is that it ignored the "[Default Applications]" section in mimeapps.list. I think that may have been added recently. I have updated the package to parse that section for now. I need to check if that is standard behavior and if defaults.list is now deprecated.


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#3 2012-06-02 17:23:43

ninian
Member
From: United Kingdom
Registered: 2008-02-24
Posts: 726
Website

Re: [solved] XDG_DATA_DIRS: Why is order of paths non-standard?

Xyne wrote:

File a bug report for. The default path is set by /etc/profile.d/xorg.sh, which belongs to the libx11 package.

Done - see https://bugs.archlinux.org/task/30113

Xyne wrote:

Mimeo cannot possibly know if the order of the environment variable is "wrong". It respects the XDG standards and loads files such that those that occur first in the path take precedence.
The only possibly bug with Mimeo here is that it ignored the "[Default Applications]" section in mimeapps.list. I think that may have been added recently. I have updated the package to parse that section for now. I need to check if that is standard behavior and if defaults.list is now deprecated.

As I'm not using ANY other defaults.list or mimeapps.list files except /usr/local/share/applications/mimeapps.list, I would have thought that mimeo would have picked up the defaults from here, regardless of whether the paths in $XDG_DATA_DIRS were reversed or not. Or maybe I'm misunderstanding how this should work. (Interestingly, it looks as though spacefm DOES pick up the defaults correctly in this situation, regardless of the path order in $XDG_DATA_DIRS.) Mimeo is a great utility which certainly simplifies all this xdg-open stuff, and it must be a pain to try to keep it conforming to the quasi-standards!

Offline

#4 2012-06-02 21:08:08

dkasak
Member
Registered: 2012-01-18
Posts: 7

Re: [solved] XDG_DATA_DIRS: Why is order of paths non-standard?

Xyne wrote:

The only possibly bug with Mimeo here is that it ignored the "[Default Applications]" section in mimeapps.list. I think that may have been added recently. I have updated the package to parse that section for now. I need to check if that is standard behavior and if defaults.list is now deprecated.

IIUC, mimeapps.list should not have a [Default Applications] section and defaults.list was never standard[1]. After the .desktop specification, there was a need for DEs / distributions to specify sane default applications for each mimetype. KDE solved this by using the InitialPreference key in the .desktop files while Gnome created defaults.list. Afterwards, freedesktop.org came up with the user-specified application ordering (i.e. mimeapps.list) but xdg-tools continued to use defaults.list for a long time for some reason and they were only fixed relatively recently (sigh). This is where the confusion likely stemmed from.

defaults.list is still not standard, though there seems to be a tentative concensus (if you could even call it that) at freedesktop.org that it is the way DEs should specify their shipped defaults[2]. Even then, it's only supposed to be a read-only file supplied by DE upstream; administrators and users should *always* use mimeapps.list (/usr/share, /usr/local/share and $HOME/.local/share for distribution-wide, site-specific and user-specific preferences, respectively). Also, order within a particular mimetype key inside mimeapps.list matters and specifies order of preference from highest to lowest.

So, really, I don't think there is anything wrong with Mimeo in this case and it does a terrific job; better than the xdg-tools which are supposed to be a reference implementation. I patched a few very bad bugs in them a few months ago that completely prevented xdg-mime/xdg-open from functioning properly. Unfortunately, I got caught up in stuff and never got the time to properly document/bugrep and send them in.

[1] - http://www.freedesktop.org/wiki/Specifi … tions-spec
[2] - http://article.gmane.org/gmane.comp.fre … p.xdg/9839
        http://article.gmane.org/gmane.comp.fre … p.xdg/9867

Offline

#5 2012-06-02 21:43:28

ninian
Member
From: United Kingdom
Registered: 2008-02-24
Posts: 726
Website

Re: [solved] XDG_DATA_DIRS: Why is order of paths non-standard?

Just confirmed that moving my mimeapps.list from /usr/local/share/applications/ to ~/.local/share/applications/ or /usr/share/applications/ DOES work with mimeo; it picks up the default applications correctly. So, it is only when mimeapps.list is within /usr/local/share/applications/ that I have trouble with mimeo.

Version 1.5.0-1 of libx11 has now fixed the ordering of the paths in XDG_DATA_DIRS, so mimeo should be happier again.

Last edited by ninian (2012-06-02 21:57:12)

Offline

#6 2012-06-02 22:35:43

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,963
Website

Re: [solved] XDG_DATA_DIRS: Why is order of paths non-standard?

@dkasak
Thanks for the thorough explanation and the links. That will be useful when I finally find the time to rewrite Mimeo. I remember that when I wrote it, it was difficult to track down some of the specifications.

@ninian
I get the impression that you didn't read my post carefully. I said that I had updated Mimeo to parse a new section in the mimeapps.list file, which was not there before. That is why it works. The order of the paths does not have any effect whatsoever if there is only one file somewhere on one of those paths. Furthermore, it always read every existing file on those paths. The only thing the order does is determine the precedence of each file, but they are all loaded cumulatively.

Again, the  problem was that there is now a new "Default Applications" which, as dkasak explained, is not actually a part of the standard. The last update of Mimeo adds support for it.


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#7 2012-06-02 23:14:46

ninian
Member
From: United Kingdom
Registered: 2008-02-24
Posts: 726
Website

Re: [solved] XDG_DATA_DIRS: Why is order of paths non-standard?

Xyne wrote:

@ninian
I get the impression that you didn't read my post carefully. I said that I had updated Mimeo to parse a new section in the mimeapps.list file, which was not there before. That is why it works ... Again, the  problem was that there is now a new "Default Applications" which, as dkasak explained, is not actually a part of the standard. The last update of Mimeo adds support for it.

Your post was indeed read carefully, but the [Default Applications] section has never been present in my mimeapps.list file, only an [Added Associations] section, as mentioned in my very first post. So adding the [Default Applications] parsing is irrelevant to my problem and not why mimeo now works. In any case, I checked that the problem remained after today's parsing update to mimeo. The only thing which has made it work now is the change to the ordering of the paths in $XDG_DATA_DIRS, enabled by the updated libx11 1.5.0-1.

Here's some output which should put it across much better than I've explained so far:

user@pc:~ $ echo $XDG_DATA_DIRS
/usr/local/share/:/usr/share/

user@pc:~ $ pacman -Q mimeo libx11
mimeo 2012.6-1
libx11 1.5.0-1

user@pc:~ $ mimeo -c babyhedge2.jpg 
sxiv babyhedge2.jpg

user@pc:~ $ mimeo -d babyhedge2.jpg
babyhedge2.jpg
  sxiv.desktop             /usr/local/share/applications/sxiv.desktop     
  shotwell-viewer.desktop  /usr/share/applications/shotwell-viewer.desktop
  gqview.desktop           /usr/share/applications/gqview.desktop         
  xfi.desktop              /usr/share/applications/xfi.desktop            
  mtpaint.desktop          /usr/share/applications/mtpaint.desktop        
  fotoxx.desktop           /usr/share/applications/fotoxx.desktop         
  gpicview.desktop         /usr/share/applications/gpicview.desktop       
  gimp.desktop             /usr/share/applications/gimp.desktop           
  mirage.desktop           /usr/share/applications/mirage.desktop         
  geeqie.desktop           /usr/share/applications/geeqie.desktop         

user@pc:~ $ XDG_DATA_DIRS="/usr/share/:/usr/local/share/" mimeo -c babyhedge2.jpg 
shotwell babyhedge2.jpg

user@pc:~ $ XDG_DATA_DIRS="/usr/share/:/usr/local/share/" mimeo -d babyhedge2.jpg 
babyhedge2.jpg
  shotwell-viewer.desktop  /usr/share/applications/shotwell-viewer.desktop
  gqview.desktop           /usr/share/applications/gqview.desktop         
  xfi.desktop              /usr/share/applications/xfi.desktop            
  mtpaint.desktop          /usr/share/applications/mtpaint.desktop        
  fotoxx.desktop           /usr/share/applications/fotoxx.desktop         
  gpicview.desktop         /usr/share/applications/gpicview.desktop       
  gimp.desktop             /usr/share/applications/gimp.desktop           
  mirage.desktop           /usr/share/applications/mirage.desktop         
  geeqie.desktop           /usr/share/applications/geeqie.desktop         
  sxiv.desktop             /usr/local/share/applications/sxiv.desktop

user@pc:~ $ cat /usr/local/share/applications/mimeapps.list 
[Added Associations]
application/epub+zip=FBReader.desktop
<cut>
image/bmp=sxiv.desktop
image/gif=gifview.desktop
image/jpeg=sxiv.desktop
image/jpg=sxiv.desktop
image/png=sxiv.desktop
etc

user@pc:~ $ ls /usr/{,local/}share/applications/{defaults,mimeapps}.list
ls: cannot access /usr/share/applications/defaults.list: No such file or directory
ls: cannot access /usr/share/applications/mimeapps.list: No such file or directory
ls: cannot access /usr/local/share/applications/defaults.list: No such file or directory
/usr/local/share/applications/mimeapps.list
user@pc:~ $ ls ~/.local/share/applications/{defaults,mimeapps}.list
ls: cannot access /home/user/.local/share/applications/defaults.list: No such file or directory
ls: cannot access /home/user/.local/share/applications/mimeapps.list: No such file or directory

Of course, sxiv should be the default application regardless.
wink

Edit: more output added for clarity

Last edited by ninian (2012-06-02 23:27:38)

Offline

#8 2012-06-03 04:36:26

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,963
Website

Re: [solved] XDG_DATA_DIRS: Why is order of paths non-standard?

Ok, the extra output helped. Look at the order of the desktop files.

ninian wrote:

user@pc:~ $ XDG_DATA_DIRS="/usr/share/:/usr/local/share/" mimeo -d babyhedge2.jpg
babyhedge2.jpg
  shotwell-viewer.desktop  /usr/share/applications/shotwell-viewer.desktop
  gqview.desktop           /usr/share/applications/gqview.desktop         
  xfi.desktop              /usr/share/applications/xfi.desktop           
  mtpaint.desktop          /usr/share/applications/mtpaint.desktop       
  fotoxx.desktop           /usr/share/applications/fotoxx.desktop         
  gpicview.desktop         /usr/share/applications/gpicview.desktop       
  gimp.desktop             /usr/share/applications/gimp.desktop           
  mirage.desktop           /usr/share/applications/mirage.desktop         
  geeqie.desktop           /usr/share/applications/geeqie.desktop         
  sxiv.desktop             /usr/local/share/applications/sxiv.desktop

I think the associations are picked up from the mimeinfo.cache file even if mimeapps.list doesn't exist. That is also expected behavior if I remember correctly. You have to dissociate desktop files with a mimeapps.list file if you want to ignore them.

You spoke of "defaults" in the original post, but these are actually associations. The application is chosen in the following order:

1) user defaults
2) system defaults
3) user associations
4) system associations


I also saw that you have edited your original post. Please mark your edits clearly in the future. It maintains the context of following posts which provides clarity for the reader and avoids making other posters appear foolish.


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#9 2012-06-03 08:31:44

ninian
Member
From: United Kingdom
Registered: 2008-02-24
Posts: 726
Website

Re: [solved] XDG_DATA_DIRS: Why is order of paths non-standard?

Xyne wrote:

I think the associations are picked up from the mimeinfo.cache file even if mimeapps.list doesn't exist. That is also expected behavior if I remember correctly.

My understanding as well. Runniung 'update-desktop-database' as root updates /usr/share/applications/mimeinfo.cache and /usr/local/share/applications/mimeinfo.cache only.

Xyne wrote:

You spoke of "defaults" in the original post, but these are actually associations. The application is chosen in the following order:

1) user defaults
2) system defaults
3) user associations
4) system associations

Fair enough, and I suppose we should be talking about the "preferred" (rather than default) application. If the preferred application is the first one "hit" going through the above order, that makes sense. For folk reading this who are confused, here's the relevant extract from http://www.freedesktop.org/wiki/Specifi … tions-spec:

Default application ordering
This hasn't been finalized in a cross-desktop way yet; especially since the default application is probably desktop specific
in some cases ... 
However, note that the next section provides another solution for ISV applications which want to ensure they become
the default application after being installed: they can edit [or create] the global mimeapps.list file in /usr/share/applications.
This is also a solution for system administrators who wish to set up a default application ordering for their users.

User-specified application ordering
Users can change the default order of applications by writing (using graphical tools, of course) into the file
~/.local/share/applications/mimeapps.list

The syntax of this file is:
[Added Associations]
mimetype1=foo1.desktop;foo2.desktop;foo3.desktop;
mimetype2=foo4.desktop;
[Removed Associations]
mimetype1=foo5.desktop;
This means that foo1 is the preferred application for mimetype1, but if it is not installed then foo2 is going to be used, etc.

So basically, if the paths in $XDG_DATA_DIRS are reversed, then it effectively forces the order above to be changed to 2), 1), 4), 3) presumably.

Xyne wrote:

I also saw that you have edited your original post. Please mark your edits clearly in the future.

Mea culpa, but please forgive me this time as it was only a typo in the spelling of 'Associations' I corrected. Original post now edited to state this.

Conclusion: Mimeo is innocent. libx11 1.4.99.902-1 was guilty by mixing-up the standard (paths reversed in $XDG_DATA_DIRS by xorg.sh). But libx11 1.5.0-1 is innocent (thanks to AndyRTR for the swift package fix).
smile

Edited: 1) Added "effectively" before "forces", 2) added Conclusion paragraph, 3) added Solved to title

Last edited by ninian (2012-06-03 09:27:06)

Offline

#10 2012-06-03 14:38:46

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,963
Website

Re: [solved] XDG_DATA_DIRS: Why is order of paths non-standard?

ninian wrote:
Xyne wrote:

I also saw that you have edited your original post. Please mark your edits clearly in the future.

Mea culpa, but please forgive me this time as it was only a typo in the spelling of 'Associations' I corrected. Original post now edited to state this.

Ah, I thought you had changed more than that. When someone does, the convention is to do something like this: (edit: I have already tested foo, but that does not work) or (edit: forgot to include the following output...). I appreciate that you added the clarification, but I don't want you to feel that you have to give a complete diff for typos and small changes. Just mark anything that alters the meaning or context.

It seems that I'm the one who doesn't read carefully enough. hmm


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

Board footer

Powered by FluxBB