8000 gh-85644: webbrowser: Use $XDG_CURRENT_DESKTOP to check desktop by 3v1n0 · Pull Request #21731 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-85644: webbrowser: Use $XDG_CURRENT_DESKTOP to check desktop #21731

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 2, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
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
  • Loading branch information
3v1n0 committed Feb 27, 2024
commit b0e545e88ad3a2bf44b57da7798071308bb6c82b
12 changes: 9 additions & 3 deletions Lib/webbrowser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
0