Skip to content

Commit 911c35d

Browse files
bpo-40767: Allow pure Wayland to get default XDG web browser (GH-20382)
Would be nice to backport to python 3.7+. I don't think it's worth the hassle to backport this all the way down to 3.10. But I'll let the maintainers decide. This is hard to test because the test setup already includes this [environment variable](https://github.com/python/cpython/blob/master/Lib/test/pythoninfo.pyGH-L292) Let me know if something doesn't match the PR guidelines. This is my first PR in the python source code. (cherry picked from commit c822efe) Co-authored-by: Jeremy Attali <[email protected]>
1 parent b640ca1 commit 911c35d

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

Lib/webbrowser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ def register_standard_browsers():
540540
register(browser, None, BackgroundBrowser(browser))
541541
else:
542542
# Prefer X browsers if present
543-
if os.environ.get("DISPLAY"):
543+
if os.environ.get("DISPLAY") or os.environ.get("WAYLAND_DISPLAY"):
544544
try:
545545
cmd = "xdg-settings get default-web-browser".split()
546546
raw_result = subprocess.check_output(cmd, stderr=subprocess.DEVNULL)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
:mod:`webbrowser` now properly finds the default browser in pure Wayland
2+
systems by checking the WAYLAND_DISPLAY environment variable. Patch
3+
contributed by Jérémy Attali.

0 commit comments

Comments
 (0)