From 3b4eb16110e503f7401feacde52ed521fbfeb3b0 Mon Sep 17 00:00:00 2001 From: Henry Heino <46334387+personalizedrefrigerator@users.noreply.github.com> Date: Wed, 20 Dec 2023 11:09:28 -0800 Subject: [PATCH] Desktop: Fixes #9045: Ubuntu: Fix window sometimes doesn't appear on startup (#9561) --- packages/lib/shim.ts | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/packages/lib/shim.ts b/packages/lib/shim.ts index a7c97589d..b3b628c3d 100644 --- a/packages/lib/shim.ts +++ b/packages/lib/shim.ts @@ -69,10 +69,26 @@ const shim = { }, isGNOME: () => { + if ((!shim.isLinux() && !shim.isFreeBSD()) || !process) { + return false; + } + + const currentDesktop = process.env['XDG_CURRENT_DESKTOP'] ?? ''; + // XDG_CURRENT_DESKTOP may be something like "ubuntu:GNOME" and not just "GNOME". // Thus, we use .includes and not ===. - return (shim.isLinux() || shim.isFreeBSD()) - && process && (process.env['XDG_CURRENT_DESKTOP'] ?? '').includes('GNOME'); + if (currentDesktop.includes('GNOME')) { + return true; + } + + // On Ubuntu, "XDG_CURRENT_DESKTOP=ubuntu:GNOME" is replaced with "Unity" and + // ORIGINAL_XDG_CURRENT_DESKTOP stores the original desktop. + const originalCurrentDesktop = process.env['ORIGINAL_XDG_CURRENT_DESKTOP'] ?? ''; + if (originalCurrentDesktop.includes('GNOME')) { + return true; + } + + return false; }, isFreeBSD: () => {