From b0e545e88ad3a2bf44b57da7798071308bb6c82b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 4 Aug 2020 15:24:34 +0200 Subject: [PATCH 1/3] webbrowser: Use $XDG_CURRENT_DESKTOP to check desktop Usage of $GNOME_DESKTOP_SESSION_ID env variable is deprecated since GNOME 3.30.0 [1], so should not be used, while the standard XDG_CURRENT_DESKTOP should be instead preferred. [1] https://gitlab.gnome.org/GNOME/gnome-session/-/commit/00e0e6226371d53f65 --- Lib/webbrowser.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Lib/webbrowser.py b/Lib/webbrowser.py index 636e8ca459d109..0424c53b7ccaf9 100755 --- a/Lib/webbrowser.py +++ b/Lib/webbrowser.py @@ -418,12 +418,18 @@ def register_X_browsers(): if shutil.which("gio"): register("gio", None, BackgroundBrowser(["gio", "open", "--", "%s"])) - # Equivalent of gio open before 2015 - if "GNOME_DESKTOP_SESSION_ID" in os.environ and shutil.which("gvfs-open"): + xdg_desktop = os.getenv("XDG_CURRENT_DESKTOP", "").split(":") + + # The default GNOME3 browser + if (("GNOME" in xdg_desktop or + "GNOME_DESKTOP_SESSION_ID" in os.environ) and + shutil.which("gvfs-open")): register("gvfs-open", None, BackgroundBrowser("gvfs-open")) # The default KDE browser - if "KDE_FULL_SESSION" in os.environ and shutil.which("kfmclient"): + if (("KDE" in xdg_desktop or + "KDE_FULL_SESSION" in os.environ) and + shutil.which("kfmclient")): register("kfmclient", Konqueror, Konqueror("kfmclient")) # Common symbolic link for the default X11 browser From 407a580bb2cee922793885e99b20a76b49dd1469 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Tue, 27 Feb 2024 20:11:30 +0000 Subject: [PATCH 2/3] News: Add NEWS for the change MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 📜🤖 Added by blurb_it. --- .../Library/2024-02-27-20-11-29.gh-issue-85644.3rgcBm.rst | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 Misc/NEWS.d/next/Library/2024-02-27-20-11-29.gh-issue-85644.3rgcBm.rst diff --git a/Misc/NEWS.d/next/Library/2024-02-27-20-11-29.gh-issue-85644.3rgcBm.rst b/Misc/NEWS.d/next/Library/2024-02-27-20-11-29.gh-issue-85644.3rgcBm.rst new file mode 100644 index 00000000000000..41fb3924e8ddc0 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2024-02-27-20-11-29.gh-issue-85644.3rgcBm.rst @@ -0,0 +1,7 @@ +webbrowser: Use ``$XDG_CURRENT_DESKTOP`` to check desktop + +Usage of ``$GNOME_DESKTOP_SESSION_ID`` env variable is deprecated since +`GNOME 3.30.0`_, so while python will still support it, prefer use +``$XDG_CURRENT_DESKTOP`` instead. + +.. _GNOME 3.30.0: https://gitlab.gnome.org/GNOME/gnome-session/-/commit/00e0e6226371d53f65 From c0664b528f7cf505a30e116e97343c667e9b2c50 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Sat, 2 Mar 2024 14:23:34 +0200 Subject: [PATCH 3/3] Update 2024-02-27-20-11-29.gh-issue-85644.3rgcBm.rst --- .../2024-02-27-20-11-29.gh-issue-85644.3rgcBm.rst | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/Misc/NEWS.d/next/Library/2024-02-27-20-11-29.gh-issue-85644.3rgcBm.rst b/Misc/NEWS.d/next/Library/2024-02-27-20-11-29.gh-issue-85644.3rgcBm.rst index 41fb3924e8ddc0..818f7046229878 100644 --- a/Misc/NEWS.d/next/Library/2024-02-27-20-11-29.gh-issue-85644.3rgcBm.rst +++ b/Misc/NEWS.d/next/Library/2024-02-27-20-11-29.gh-issue-85644.3rgcBm.rst @@ -1,7 +1,2 @@ -webbrowser: Use ``$XDG_CURRENT_DESKTOP`` to check desktop - -Usage of ``$GNOME_DESKTOP_SESSION_ID`` env variable is deprecated since -`GNOME 3.30.0`_, so while python will still support it, prefer use -``$XDG_CURRENT_DESKTOP`` instead. - -.. _GNOME 3.30.0: https://gitlab.gnome.org/GNOME/gnome-session/-/commit/00e0e6226371d53f65 +Use the ``XDG_CURRENT_DESKTOP`` environment variable in :mod:`webbrowser` to check desktop. +Prefer it to the deprecated ``GNOME_DESKTOP_SESSION_ID`` for GNOME detection.