diff --git a/browsers/__init__.py b/browsers/__init__.py index b96660a..ee48cb1 100644 --- a/browsers/__init__.py +++ b/browsers/__init__.py @@ -72,7 +72,11 @@ def _launch(browser: str, path: str, args: Sequence[str], url: str = None) -> su elif url is not None: url_arg.append(url) - if sys.platform != "linux": + if browser == "safari": + if args: + logger.warning("Safari does not accept command line arguments. %s will be ignored.", str(args)) + command = ["open", "--wait-apps", "--new", "--fresh", "-a", path, *url_arg] + elif sys.platform != "linux": command = [path, *url_arg, *args] else: command = [*shlex.split(path), *url_arg, *args] diff --git a/browsers/osx.py b/browsers/osx.py index d99f472..3a510a5 100644 --- a/browsers/osx.py +++ b/browsers/osx.py @@ -38,4 +38,6 @@ def browsers() -> Iterator[Tuple[str, Dict]]: # type: ignore[return] executable = os.path.join(path, "Contents/MacOS", executable_name) display_name = plist.get("CFBundleDisplayName") or plist.get("CFBundleName", browser) version = plist[version_string] - yield browser, dict(path=executable, display_name=display_name, version=version) + yield browser, dict( + path=executable if browser != "safari" else path, display_name=display_name, version=version + ) diff --git a/pyproject.toml b/pyproject.toml index ab3fa34..3fc7c64 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "pybrowsers" -version = "0.3.0" +version = "0.3.1" repository = "https://github.com/roniemartinez/browsers" description = "Python library for detecting and launching browsers" authors = ["Ronie Martinez "] diff --git a/tests/test_detect.py b/tests/test_detect.py index 0146a9d..9f2ee8e 100644 --- a/tests/test_detect.py +++ b/tests/test_detect.py @@ -55,7 +55,7 @@ def test_get_available_browsers(browser: str) -> None: "safari", { "display_name": "Safari", - "path": "/Applications/Safari.app/Contents/MacOS/Safari", + "path": "/Applications/Safari.app", "version": ANY, }, marks=pytest.mark.skipif(sys.platform != "darwin", reason="osx-only"),