Fix handling of XDG directories in TDEConfigBase. This relates to issue #60. #61
Merged
MicheleC
merged 1 commits from fix/xdg-dirs
into master
4 years ago
Loading…
Reference in new issue
There is no content yet.
Delete Branch 'fix/xdg-dirs'
Deleting a branch is permanent. It CANNOT be undone. Continue?
This fix allows TDEConfigBase readEntry to parse XDG directories. Process is as follow:
So this solution is able to work correctly either the variables are defined in the environment or not.
MicheleC referenced this pull request 4 years agoIt is great that it has been able to use the already read values instead of repeated parsing the file or calling an external command.
However, I see there one problem that needs to be examined.
else {
// remove one of the dollar signs
aValue.remove( nDollarPos, 1 );
nDollarPos++;
I believe that this removal of the index increase is wrong.
The dollar sign is used to expand the variable. If you need to write a dollar sign as such, the usual way is to double the dollar sign.
The code respected this rule - the first dollar sign was removed, and to prevent the next dollar sign from being seen as an instruction to expand the variable, the index was increased to ensure that the second dollar sign was left unexpanded.
Removing the index increase causes the second dollar sign to be processed to expand the variable and to be deleted. So it will have two negative effects:
ah ah, that is what it was for! Now I understand. Will fix it.
Done, rectified!
It looks good. I have no further objections.
@MicheleC: The idea is good. I will test tomorrow too. I like you re-used much of the code. 👍
It would be good if you would add support for all XGD directories. They are some missing. So TDE would have complete support. Could you add that? That would be wonderful. 😸
Also, from my understanding, there is need for other old kxdglauncher code too, to create these directories, if they are not already existing. That was the point about the old launcher and the prompter and GNOME and most likely other DE's are doing it that way too. So if you install TDE on a new Computer and there isn't xdg-user-dirs installed, and/or also no config file for it and/or no dirs existing at all, you should get prompted every time you click on a desktop file (or some access to that dirs) to create them and give them a own name - You can do that over some kcontrol module too - But that only after install and setup of your new TDE install and at start the URL's just would not work correctly - Not to say the kcontrol module most likely does not create them and just changes the config file, which I haven't tested so far.
So that code should be re-used just too. So that the kxdglauncher code would just end up in tdelibs, which is more central anyway, so it is no bad idea.
Otherwise we would end up with not existing dirs.
Other DE's are doing it that way it seems, like the kxdglauncher did it before:
https://github.com/GNOME/xdg-user-dirs-gtk
Otherwise you would install TDE and end up with broken desktop files, after all, from my understanding. Before, if you installed TDE the first time and had none of that dirs, you got prompted to create them. That was a nice usability feature of TDE. But just doing that on another place in the code should be fine too.
Now your idea just to put that code from kxdglauncher and to re-use the existing read-out code in tdelibs, is an very good idea. This way we can still keep the desktop files use the correct URL= and not EXEC= and also I very much like the fact that code also can work without xdg-user-dirs binary to have installed at all. So just defining the variables or having that old config file should be enough. Glad you did that latest change. 👍
@Chris:
yes, there are a couple of missing xdg folders not included yet. I am already planning to add support for them 😉
kxdglauncher is not used anywhere in TDE now and before it was used only for the "my documents" .desktop file. kdesktop-trinity has a dependency on xdg-user-dirs, at least in debian world, so as long as TDE is installed, xdg-user-dirs get pulled in too. I made a test with a user for which I had removed the config file for the user dirs and upon login, the folders are correctly pre-initialized to sane values.
Moreover kxdglauncher was only supporting the desktop and document folders, not the other ones.
Based on this, I think it is reasonably safe to remove kxdglauncher, I don't see new problems coming from that.
See TDE/tdebase#121 for removal of kxdglauncher.
@Chris support for the two missing xdg variables added into tdelibs.
@MicheleC: Perfect. Thank you. 👍
It's good you tested that already and it's interesting, because before, you got always instantly prompted to create your XDG dirs (so documents dir) when you started a TDE session for a first time. So someone had to trigger that. It might be that this was just triggered by accessing the documents dir while that process?
Yes, I know it was only about the documents dir at the moment, so I suggested to add other XDG dirs too. Okay, if there are new problems there will be some way to fix them too, for sure. 😸
"Yes, I know it was only about the documents dir at the moment, so I suggested to add other XDG dirs too. Okay, if there are new problems there will be some way to fix them too, for sure."
@Chris yes, the idea is to remove kxdglauncher and then if there are some problems we will fix it in tdelibs in a more appropriate way.
If you have time please review TDE/tdebase#121 and let me know what you think.
3a4f7f51cf
.