aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib-python/3/webbrowser.py')
-rwxr-xr-xlib-python/3/webbrowser.py20
1 files changed, 18 insertions, 2 deletions
diff --git a/lib-python/3/webbrowser.py b/lib-python/3/webbrowser.py
index 82bff835fd..b04ec7b65a 100755
--- a/lib-python/3/webbrowser.py
+++ b/lib-python/3/webbrowser.py
@@ -69,6 +69,14 @@ def get(using=None):
# instead of "from webbrowser import *".
def open(url, new=0, autoraise=True):
+ """Display url using the default browser.
+
+ If possible, open url in a location determined by new.
+ - 0: the same browser window (the default).
+ - 1: a new browser window.
+ - 2: a new browser page ("tab").
+ If possible, autoraise raises the window (the default) or not.
+ """
if _tryorder is None:
with _lock:
if _tryorder is None:
@@ -80,14 +88,22 @@ def open(url, new=0, autoraise=True):
return False
def open_new(url):
+ """Open url in a new window of the default browser.
+
+ If not possible, then open url in the only browser window.
+ """
return open(url, 1)
def open_new_tab(url):
+ """Open url in a new page ("tab") of the default browser.
+
+ If not possible, then the behavior becomes equivalent to open_new().
+ """
return open(url, 2)
def _synthesize(browser, *, preferred=False):
- """Attempt to synthesize a controller base on existing controllers.
+ """Attempt to synthesize a controller based on existing controllers.
This is useful to create a controller when a user specifies a path to
an entry in the BROWSER environment variable -- we can copy a general
@@ -524,7 +540,7 @@ def register_standard_browsers():
register(browser, None, BackgroundBrowser(browser))
else:
# Prefer X browsers if present
- if os.environ.get("DISPLAY"):
+ if os.environ.get("DISPLAY") or os.environ.get("WAYLAND_DISPLAY"):
try:
cmd = "xdg-settings get default-web-browser".split()
raw_result = subprocess.check_output(cmd, stderr=subprocess.DEVNULL)