summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarco Trevisan <mail@3v1n0.net>2024-03-02 12:48:24 (GMT)
committerGitHub <noreply@github.com>2024-03-02 12:48:24 (GMT)
commit140d9ec4bcf969b62a742f81e2892fe04a44b6ac (patch)
tree6c097d34a943f8a21953bd3a7a19c2a139d535d6
parent5dc8c84d397110f9edfa56793ad8887b1f176d79 (diff)
downloadcpython-140d9ec4bcf969b62a742f81e2892fe04a44b6ac.zip
cpython-140d9ec4bcf969b62a742f81e2892fe04a44b6ac.tar.gz
cpython-140d9ec4bcf969b62a742f81e2892fe04a44b6ac.tar.bz2
gh-85644: webbrowser: Use $XDG_CURRENT_DESKTOP to check desktop (GH-21731)
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
-rwxr-xr-xLib/webbrowser.py12
-rw-r--r--Misc/NEWS.d/next/Library/2024-02-27-20-11-29.gh-issue-85644.3rgcBm.rst2
2 files changed, 11 insertions, 3 deletions
diff --git a/Lib/webbrowser.py b/Lib/webbrowser.py
index 636e8ca..0424c53 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
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 0000000..818f704
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2024-02-27-20-11-29.gh-issue-85644.3rgcBm.rst
@@ -0,0 +1,2 @@
+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.