[PATCH v2 0/2] MR10543: Change default dir to ~/.local/share/wine
I switched it to `~/.local/share/wine` to fit XDG. I will edit all the docs and what not if `~/.local/share/wine` is see fit by maintainers. Soo please let me know if it's fit or not {width=900 height=234} If $XDG_DATA_HOME isn't set on the machine + .local doesn't exist it uses the current `$HOME/.wine` Related issue (please see beforehand): https://bugs.winehq.org/show_bug.cgi?id=48955 -- v2: Stop hardcoding https://gitlab.winehq.org/wine/wine/-/merge_requests/10543
From: Twig6943 <119701717+Twig6943@users.noreply.github.com> --- dlls/mountmgr.sys/unixlib.c | 2 +- dlls/ntdll/unix/loader.c | 2 +- server/request.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dlls/mountmgr.sys/unixlib.c b/dlls/mountmgr.sys/unixlib.c index 2a5fd272db6..f84027f36ef 100644 --- a/dlls/mountmgr.sys/unixlib.c +++ b/dlls/mountmgr.sys/unixlib.c @@ -99,7 +99,7 @@ static char *get_dosdevices_path( const char *dev ) if (prefix) asprintf( &path, "%s/dosdevices/%s", prefix, dev ); else - asprintf( &path, "%s/.wine/dosdevices/%s", getenv( "HOME" ), dev ); + asprintf( &path, "%s/.local/share/wine/dosdevices/%s", getenv( "HOME" ), dev ); return path; } diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c index b66be2bb06e..914eb9a0116 100644 --- a/dlls/ntdll/unix/loader.c +++ b/dlls/ntdll/unix/loader.c @@ -378,7 +378,7 @@ static void set_config_dir(void) { if (!home_dir) fatal_error( "could not determine your home directory\n" ); if (home_dir[0] != '/') fatal_error( "the home directory %s is not an absolute path\n", home_dir ); - config_dir = build_path( home_dir, ".wine" ); + config_dir = build_path( home_dir, ".local/share/wine" ); } } diff --git a/server/request.c b/server/request.c index 994169a0565..18031abcaa1 100644 --- a/server/request.c +++ b/server/request.c @@ -619,10 +619,10 @@ static char *create_server_dir( int force ) } if (!home) fatal_error( "could not determine your home directory\n" ); if (home[0] != '/') fatal_error( "your home directory %s is not an absolute path\n", home ); - if (!(config_dir = malloc( strlen(home) + sizeof("/.wine") ))) fatal_error( "out of memory\n" ); + if (!(config_dir = malloc( strlen(home) + sizeof("/.local/share/wine") ))) fatal_error( "out of memory\n" ); strcpy( config_dir, home ); for (p = config_dir + strlen(config_dir); p > config_dir; p--) if (p[-1] != '/') break; - strcpy( p, "/.wine" ); + strcpy( p, "/.local/share/wine" ); } if (chdir( config_dir ) == -1) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10543
From: Twig6943 <119701717+Twig6943@users.noreply.github.com> --- dlls/mountmgr.sys/unixlib.c | 21 +++++++++++++++++++-- dlls/ntdll/unix/loader.c | 13 ++++++++++++- server/request.c | 26 ++++++++++++++++++++++---- 3 files changed, 53 insertions(+), 7 deletions(-) diff --git a/dlls/mountmgr.sys/unixlib.c b/dlls/mountmgr.sys/unixlib.c index f84027f36ef..e1b10169c92 100644 --- a/dlls/mountmgr.sys/unixlib.c +++ b/dlls/mountmgr.sys/unixlib.c @@ -99,8 +99,25 @@ static char *get_dosdevices_path( const char *dev ) if (prefix) asprintf( &path, "%s/dosdevices/%s", prefix, dev ); else - asprintf( &path, "%s/.local/share/wine/dosdevices/%s", getenv( "HOME" ), dev ); - + { + const char *xdg_data_home = getenv( "XDG_DATA_HOME" ); + const char *home = getenv( "HOME" ); + char *data_home; + struct stat st; + if (xdg_data_home && xdg_data_home[0] == '/') + { + if (!(data_home = strdup( xdg_data_home ))) return NULL; + } + else + { + if (!home || asprintf( &data_home, "%s/.local/share", home ) == -1) return NULL; + } + if (stat( data_home, &st ) == 0 && S_ISDIR(st.st_mode)) + asprintf( &path, "%s/wine/dosdevices/%s", data_home, dev ); + else if (home) + asprintf( &path, "%s/.wine/dosdevices/%s", home, dev ); + free( data_home ); + } return path; } diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c index 914eb9a0116..1b9d1522537 100644 --- a/dlls/ntdll/unix/loader.c +++ b/dlls/ntdll/unix/loader.c @@ -376,9 +376,20 @@ static void set_config_dir(void) } else { + const char *xdg_data_home = getenv( "XDG_DATA_HOME" ); + char *data_home; + struct stat st; if (!home_dir) fatal_error( "could not determine your home directory\n" ); if (home_dir[0] != '/') fatal_error( "the home directory %s is not an absolute path\n", home_dir ); - config_dir = build_path( home_dir, ".local/share/wine" ); + if (xdg_data_home && xdg_data_home[0] == '/') + data_home = strdup( xdg_data_home ); + else + data_home = build_path( home_dir, ".local/share" ); + if (stat( data_home, &st ) == 0 && S_ISDIR(st.st_mode)) + config_dir = build_path( data_home, "wine" ); + else + config_dir = build_path( home_dir, ".wine" ); + free( data_home ); } } diff --git a/server/request.c b/server/request.c index 18031abcaa1..7d2eae5bec5 100644 --- a/server/request.c +++ b/server/request.c @@ -612,6 +612,8 @@ static char *create_server_dir( int force ) else { const char *home = getenv( "HOME" ); + const char *xdg_data_home = getenv( "XDG_DATA_HOME" ); + char *data_home; if (!home) { struct passwd *pwd = getpwuid( getuid() ); @@ -619,10 +621,26 @@ static char *create_server_dir( int force ) } if (!home) fatal_error( "could not determine your home directory\n" ); if (home[0] != '/') fatal_error( "your home directory %s is not an absolute path\n", home ); - if (!(config_dir = malloc( strlen(home) + sizeof("/.local/share/wine") ))) fatal_error( "out of memory\n" ); - strcpy( config_dir, home ); - for (p = config_dir + strlen(config_dir); p > config_dir; p--) if (p[-1] != '/') break; - strcpy( p, "/.local/share/wine" ); + if (xdg_data_home && xdg_data_home[0] == '/') + { + if (!(data_home = strdup( xdg_data_home ))) fatal_error( "out of memory\n" ); + } + else + { + if (asprintf( &data_home, "%s/.local/share", home ) == -1) fatal_error( "out of memory\n" ); + } + if (stat( data_home, &st ) == 0 && S_ISDIR(st.st_mode)) + { + if (asprintf( &config_dir, "%s/wine", data_home ) == -1) fatal_error( "out of memory\n" ); + } + else + { + if (!(config_dir = malloc( strlen(home) + sizeof("/.wine") ))) fatal_error( "out of memory\n" ); + strcpy( config_dir, home ); + for (p = config_dir + strlen(config_dir); p > config_dir; p--) if (p[-1] != '/') break; + strcpy( p, "/.wine" ); + } + free( data_home ); } if (chdir( config_dir ) == -1) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10543
On Thu Apr 2 13:26:30 2026 +0000, Fatih Bakal wrote:
The latest commit seems good? I think keeping $HOME/.wine as a fallback is also good for Linux/BSD desktops that don't support XDG (headless server?). For macOS, maybe we will prefer using something like "\$HOME/Library/Application\ Support/Wine" instead.
Personally, changes like this for reducing dot files/folders under $HOME are welcome to me, but there is a concern that users will lose their configuration and applications in the old wine prefix if they don't notice this change and copy their wine prefix to the new location, this can be confusing. Please also squash patches that are for the same purpose into a single commit. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10543#note_134825
On Thu Apr 2 14:31:29 2026 +0000, Jactry Zeng wrote:
I think keeping $HOME/.wine as a fallback is also good for Linux/BSD desktops that don't support XDG (headless server?). For macOS, maybe we will prefer using something like "\$HOME/Library/Application\ Support/Wine" instead. Personally, changes like this for reducing dot files/folders under $HOME are welcome to me, but there is a concern that users will lose their configuration and applications in the old wine prefix if they don't notice this change and copy their wine prefix to the new location, this can be confusing. Please also squash patches that are for the same purpose into a single commit. I'd prefer using $HOME/.wine/ if it exists, but never creating it; if it doesn't, use $XDG_DATA_DIR/wine/, or $HOME/.local/share/wine/ if that env isn't set either. My system (Debian+MATE) has a well populated ~/.local/share/, but doesn't set $XDG_DATA_DIR.
Also, if we're going to consider four or five locations ($WINEPREFIX, $HOME/.wine/, $XDG_DATA_HOME/wine/, $HOME/.local/share/wine/, $HOME/Library/Application Support/Wine/), we should probably not duplicate that logic three times. Better refactor it to a shared function. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10543#note_134830
On Thu Apr 2 15:00:34 2026 +0000, Alfred Agrell wrote:
I'd prefer using $HOME/.wine/ if it exists, but never creating it; if it doesn't, use $XDG_DATA_DIR/wine/, or $HOME/.local/share/wine/ if that env isn't set either. My system (Debian+MATE) has a well populated ~/.local/share/, but doesn't set $XDG_DATA_DIR. Also, if we're going to consider four or five locations ($WINEPREFIX, $HOME/.wine/, $XDG_DATA_HOME/wine/, $HOME/.local/share/wine/, $HOME/Library/Application Support/Wine/), we should probably not duplicate that logic three times. Better refactor it to a shared function. @jactry will squash once I'm it's done (still waiting on word from upstream people as I said)
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/10543#note_134831
On Thu Apr 2 15:05:09 2026 +0000, Fatih Bakal wrote:
@jactry will squash once I'm it's done (still waiting on word from upstream people as I said) Also I dont have mac hardware to test not to mention I think apple stuff isn't worth touching (not gonna rant why here)
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/10543#note_134834
participants (4)
-
Alfred Agrell (@Alcaro) -
Fatih Bakal (@Twig) -
Jactry Zeng (@jactry) -
Twig6943