From 54ff423dac210ce5f29cb4c297dc90d7eca00df4 Mon Sep 17 00:00:00 2001 From: Samuel Attard Date: Tue, 12 May 2020 20:13:53 -0700 Subject: [PATCH] fix: leave behind the unmodified XDG_CURRENT_DESKTOP variable (#23512) --- docs/api/environment-variables.md | 11 +++++++++++ lib/browser/init.ts | 1 + 2 files changed, 12 insertions(+) diff --git a/docs/api/environment-variables.md b/docs/api/environment-variables.md index cae7df9f6897..943f44b499f1 100644 --- a/docs/api/environment-variables.md +++ b/docs/api/environment-variables.md @@ -147,3 +147,14 @@ the one downloaded by `npm install`. Usage: ```sh export ELECTRON_OVERRIDE_DIST_PATH=/Users/username/projects/electron/out/Testing ``` + +## Set By Electron + +Electron sets some variables in your environment at runtime. + +### `ORIGINAL_XDG_CURRENT_DESKTOP` + +This variable is set to the value of `XDG_CURRENT_DESKTOP` that your application +originally launched with. Electron sometimes modifies the value of `XDG_CURRENT_DESKTOP` +to affect other logic within Chromium so if you want access to the _original_ value +you should look up this environment variable instead. diff --git a/lib/browser/init.ts b/lib/browser/init.ts index 3945ac1dca5a..8a39c90681d4 100644 --- a/lib/browser/init.ts +++ b/lib/browser/init.ts @@ -186,6 +186,7 @@ function currentPlatformSupportsAppIndicator () { } // Workaround for electron/electron#5050 and electron/electron#9046 +process.env.ORIGINAL_XDG_CURRENT_DESKTOP = process.env.XDG_CURRENT_DESKTOP; if (currentPlatformSupportsAppIndicator()) { process.env.XDG_CURRENT_DESKTOP = 'Unity'; }