From 69831bbe13ca7f083b9b8118af40cfce2ac517f6 Mon Sep 17 00:00:00 2001 From: Jon Seager Date: Wed, 15 Mar 2023 13:12:16 +0000 Subject: [PATCH] fix: use XDG_DOWNLOAD_DIR as default download dir (#2615) On Linux machines that are using a desktop env which conforms to the FreeDesktop spec, users should have the XDG_DOWNLOAD_DIR variable set to specify their default download directory. This patch ensures that this directory is used if the variable is present. Hoping this will fix the following issue in the Mattermost snap: https://github.com/snapcrafters/mattermost-desktop/issues/65 --- src/common/config/defaultPreferences.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/common/config/defaultPreferences.ts b/src/common/config/defaultPreferences.ts index 2c84ca7a..2a4c2269 100644 --- a/src/common/config/defaultPreferences.ts +++ b/src/common/config/defaultPreferences.ts @@ -19,6 +19,11 @@ export const getDefaultDownloadLocation = (): string | undefined => { if (__IS_MAC_APP_STORE__) { return undefined; } + + if (process.platform === 'linux' && process.env.XDG_DOWNLOAD_DIR) { + return process.env.XDG_DOWNLOAD_DIR; + } + return path.join(os.homedir(), 'Downloads'); };