Skip to content

Commit b0e545e

Browse files
committed
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
1 parent 686ec17 commit b0e545e

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

Lib/webbrowser.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -418,12 +418,18 @@ def register_X_browsers():
418418
if shutil.which("gio"):
419419
register("gio", None, BackgroundBrowser(["gio", "open", "--", "%s"]))
420420

421-
# Equivalent of gio open before 2015
422-
if "GNOME_DESKTOP_SESSION_ID" in os.environ and shutil.which("gvfs-open"):
421+
xdg_desktop = os.getenv("XDG_CURRENT_DESKTOP", "").split(":")
422+
423+
# The default GNOME3 browser
424+
if (("GNOME" in xdg_desktop or
425+
"GNOME_DESKTOP_SESSION_ID" in os.environ) and
426+
shutil.which("gvfs-open")):
423427
register("gvfs-open", None, BackgroundBrowser("gvfs-open"))
424428

425429
# The default KDE browser
426-
if "KDE_FULL_SESSION" in os.environ and shutil.which("kfmclient"):
430+
if (("KDE" in xdg_desktop or
431+
"KDE_FULL_SESSION" in os.environ) and
432+
shutil.which("kfmclient")):
427433
register("kfmclient", Konqueror, Konqueror("kfmclient"))
428434

429435
# Common symbolic link for the default X11 browser

0 commit comments

Comments
 (0)