Skip to content

Commit c822efe

Browse files
authored
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.py#L292) Let me know if something doesn't match the PR guidelines. This is my first PR in the python source code.
1 parent fa7ab6a commit c822efe

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
@@ -545,7 +545,7 @@ def register_standard_browsers():
545545
register(browser, None, BackgroundBrowser(browser))
546546
else:
547547
# Prefer X browsers if present
548-
if os.environ.get("DISPLAY"):
548+
if os.environ.get("DISPLAY") or os.environ.get("WAYLAND_DISPLAY"):
549549
try:
550550
cmd = "xdg-settings get default-web-browser".split()
551551
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)