[SailfishDevel] xdg folder stuff: howto? more info

Alejandro Exojo suy at badopi.org
Wed Jan 8 23:13:24 UTC 2014


El Wednesday 08 January 2014, wsvries escribió:
> Thanks Reto, Jonni,
> I am still puzzled (please see harbour comments below).
> I assume that the XDG naming is only to be used in the program code
> itself (not in .pro or .yaml).
> So, I would need to replace (in .pro)
> 
> data.files = checklistsdata/*
> data.path = /home/nemo/Documents/checklistsdata
> 
> with
> 
> data.files = checklistsdata/*
> data.path = /usr/share/$NAME/checklistsdata

Seems correct. Your app is now where system things are, not where user things 
are (hint: /home is where the "home" of users is, so your application, and no 
application at all, don't belong there).
 
> and in first execution copy /usr/share/$NAME/checklistsdata to
> $XDG_CONFIG_HOME/$NAME/checklistsdata or
> $HOME/.config/$NAME/checklistsdata
> (though I would think that $XDG_DATA_HOME would be better)

That depends. Why your application needs to copy or move files? What's 
"checklistdata"?

I suggest you give a look at the FHS:

https://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard

> The problem is that (certainly in my next app with loads of map data)
> data files end up in /usr/share/$NAME.
> There is no way for the app (no root permission) to clean up the
> /usr/share/$NAME directory.

Certainly not. Things in /usr mean the system, and the system doesn't change, 
unless is being updated or something new is being installed, but is not the 
normal situation.

The data that _is_ your application belongs to /usr. That includes graphics, 
or other assets.

The data that belongs to the user, and is created or modified by the 
application belongs by the path of the user that runs the application, which 
is $HOME (/home/nemo in our case).

If the data are documents visible to the user (like a music file or a picture 
or a document), belongs in some directory of the ones that are already there 
on the phone (/home/nemo/Videos for example).

If is data that is internal to the application, like some thumbnails of 
pictures downloaded from the web, and saved only as a cache, belong in some 
hidden directory, like /home/nemo/.local/share/NAME. Although the 
".local/share" part here is hardcoded, and one user might want to change this 
using the $XDG_* variables.

-- 
Alex (a.k.a. suy) | GPG ID 0x0B8B0BC2
http://barnacity.net/ | http://disperso.net


More information about the Devel mailing list