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
Owner

This fix allows TDEConfigBase readEntry to parse XDG directories. Process is as follow:

  1. if a XDG_zzzzz_DIR variable is already defined in the environment, its value will be used.
  2. else if a XDG_zzzzz_DIR variable is not defined, "xdg-user-dirs zzzzz" will be invoked, reading the correct path from the config file.

So this solution is able to work correctly either the variables are defined in the environment or not.

This fix allows TDEConfigBase readEntry to parse XDG directories. Process is as follow: 1. if a XDG_zzzzz_DIR variable is already defined in the environment, its value will be used. 2. else if a XDG_zzzzz_DIR variable is not defined, "xdg-user-dirs zzzzz" will be invoked, reading the correct path from the config file. So this solution is able to work correctly either the variables are defined in the environment or not.
MicheleC added this to the R14.0.8 release milestone 4 years ago
SlavekB requested changes 4 years ago
SlavekB left a comment
Owner

It 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.

It 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++;
Owner

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:

  1. There will be no possibility to write the dollar sign as such.
  2. Something that happened to be behind the double dollar will be evaluated as a variable.
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: 1. There will be no possibility to write the dollar sign as such. 2. Something that happened to be behind the double dollar will be evaluated as a variable.
Poster
Owner

ah ah, that is what it was for! Now I understand. Will fix it.

ah ah, that is what it was for! Now I understand. Will fix it.
Poster
Owner

Done, rectified!

Done, rectified!
SlavekB approved these changes 4 years ago
SlavekB left a comment
Owner

It looks good. I have no further objections.

It looks good. I have no further objections.
Chris commented 4 years ago
Collaborator

@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. 👍

@MicheleC: The idea is good. I will test tomorrow too. I like you re-used much of the code. :+1: 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. :smile_cat: 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. :+1:
Poster
Owner

@Chris:

  1. yes, there are a couple of missing xdg folders not included yet. I am already planning to add support for them 😉

  2. 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.

@Chris: 1. yes, there are a couple of missing xdg folders not included yet. I am already planning to add support for them :wink: 2. 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.<br/> Moreover kxdglauncher was only supporting the desktop and document folders, not the other ones.<br/> Based on this, I think it is reasonably safe to remove kxdglauncher, I don't see new problems coming from that.
MicheleC closed this pull request 4 years ago
MicheleC closed this pull request 4 years ago
MicheleC deleted branch fix/xdg-dirs 4 years ago
Poster
Owner

See TDE/tdebase#121 for removal of kxdglauncher.

See TDE/tdebase#121 for removal of kxdglauncher.
Poster
Owner

@Chris support for the two missing xdg variables added into tdelibs.

@Chris support for the two missing xdg variables added into tdelibs.
Chris commented 4 years ago
Collaborator

@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. 😸

@MicheleC: Perfect. Thank you. :+1: 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. :smile_cat:
Poster
Owner

"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.

"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.<br/> If you have time please review TDE/tdebase#121 and let me know what you think.
The pull request has been merged as 3a4f7f51cf.
Sign in to join this conversation.
No reviewers
No Milestone
No Assignees
3 Participants
Notifications
Due Date

No due date set.

Dependencies

No dependencies set.

Reference: TDE/tdelibs#61
Loading…
There is no content yet.