winegui / WineGUI

At last, a user-friendly Wine graphical interface (mirror from Gitlab)
https://gitlab.melroy.org/melroy/winegui
GNU Affero General Public License v3.0
211 stars 10 forks source link

Config dir location #13

Closed NovA-80 closed 1 year ago

NovA-80 commented 1 year ago

The WineGUI config dir is hardcoded to ~/.winegui. But according to XDG Base Directory Specification, it should be $XDG_CONFIG_HOME/winegui, i.e. ~/.config/winegui by default.

It would be nice to change WineGUI config location respectively, so that the home dir is bloated less. :)

It seams the change can be as simple as:

diff --git a/src/general_config_file.cc b/src/general_config_file.cc
index 2154c4a..7e55a03 100644
--- a/src/general_config_file.cc
+++ b/src/general_config_file.cc
@@ -46,7 +46,7 @@ bool GeneralConfigFile::write_config_file(const GeneralConfigData& general_confi
 {
   bool success = false;
   Glib::KeyFile keyfile;
-  std::vector<std::string> config_dirs{Glib::get_home_dir(), ".winegui"};
+  std::vector<std::string> config_dirs{Glib::get_user_config_dir(), "winegui"};
   std::string config_location = Glib::build_path(G_DIR_SEPARATOR_S, config_dirs);
   std::string file_path = Glib::build_filename(config_location, "config.ini");
   try
diff --git a/src/helper.cc b/src/helper.cc
index f091c40..2d26c29 100644
--- a/src/helper.cc
+++ b/src/helper.cc
@@ -42,7 +42,7 @@
 #include <tuple>
 #include <unistd.h>

-std::vector<std::string> wineGuiDirs{Glib::get_home_dir(), ".winegui"}; /*!< WineGui config/storage directory path */
+std::vector<std::string> wineGuiDirs{Glib::get_user_config_dir(), "winegui"}; /*!< WineGui config/storage directory path */
 static string WineGuiDir = Glib::build_path(G_DIR_SEPARATOR_S, wineGuiDirs);

 std::vector<std::string> defaultWineDir{Glib::get_home_dir(), ".wine"}; /*!< Default Wine bottle location */
melroy89 commented 1 year ago

I actually fully agree! Not that long ago there was a video about this & hidden directories on the youtube channel from Brodie Robertson. My bad.

I will try to change the default config location. Maybe there is a migration path needed from old to new location.

NovA-80 commented 1 year ago

Then, probably the default location of prefixes is also worth to be changed in respect with XDG Base Directory Specification. Not ~/.winegui/prefixes, but something like $XDG_DATA_HOME/wineprefixes, i.e. ~/.local/share/wineprefixes

melroy89 commented 1 year ago

Yeah I think so. I tried to match official Wine config folder initially. But yes changing all this make sense.

The biggest problem is writing an additional migration script/code which detect the old installation and moves everything to the new locations, etc. Hopefully not breaking people setups.

NovA-80 commented 1 year ago

Yeah, the backward compatibility is the problem here. But hopefully solvable.

First, I think there is need to move the config file only but keep prefixes. Else the desktop menu items generated by WINE will break. So, the change of default prefixes location will affect just the new installs.

Second, the movement of the config file can be accomplished during the next WineGUI run. Read the config from the old location (if exists) but save to the new one. Note, that in some projects, like GIT, they even keep both config files in cascading way. But I don't think its necessary in WineGUI.

melroy89 commented 1 year ago

I was thinking if users also go back one version, the config file is gone. So I understand that git keep it in both directories.

But I agree the chance that people roll back to an older version is slim.

I can code the migration in the application. Unless cmake/deb/rpm has a built in solution cross platform for this specific use case. But I don't think so. It's indeed checking if the new location contains a config file, if not, check if there was already a config file present in the old place, and move the file(s).

Prefixes are indeed a bit more tricky, since you are right. Moving is not the issue, but as you said it might break links/menu items. The prefix location is btw stored in the winegui config file, did you noticed that?

NovA-80 commented 1 year ago

Prefixes are indeed a bit more tricky, since you are right. Moving is not the issue, but as you said it might break links/menu items. The prefix location is btw stored in the winegui config file, did you noticed that?

Yes, I did noticed. That's why I propose to change only the default location not touching the existing value.

BTW, the config file is actually pretty simple for now and user can reconfigure all from scratch pretty easily. Probably the migration code is not needed at all. :) But if the migration is done, the external way via package management sounds most appropriate. This allows to keep the code clean, and those who don't use packages are supposed to have enough skills to reconfigure all manually. :)

melroy89 commented 1 year ago

Let me check if I can work on this in weekend and see how hard the migration code needs to be in order to close this ticket.

melroy89 commented 1 year ago

@NovA-80 New Merge Request is created, ready for review: https://gitlab.melroy.org/melroy/winegui/-/merge_requests/18

You could also verify the new binary (which is not yet released), download from here: https://gitlab.melroy.org/melroy/winegui/-/jobs/15175/artifacts/browse/build_prod/ (as you noticed, is a bit more complicated than initially thought 😮 )

In the last case, try to avoid roll-back to an earlier release, to prevent potential configuration settings lose.

melroy89 commented 1 year ago

OK, I officially released the new config & data dir locations.

See version 2.1.0: https://gitlab.melroy.org/melroy/winegui/-/releases/v2.1.0