11import sys
22from typing import Optional
33
4-
54def get_current_window_linux () -> Optional [dict ]:
65 from . import xlib
76 window = xlib .get_current_window ()
@@ -16,10 +15,16 @@ def get_current_window_linux() -> Optional[dict]:
1615 return {"app" : cls , "title" : name }
1716
1817
19- def get_current_window_macos () -> Optional [dict ]:
18+ def get_current_window_macos (strategy ) -> Optional [dict ]:
2019 # TODO should we use unknown when the title is blank like the other platforms?
21- from . import macos
22- return macos .getInfo ()
20+
21+ # `jxa` is the default & preferred strategy. It includes the url + incognito status
22+ if strategy == 'jxa' :
23+ from . import macos
24+ return macos .getInfo ()
25+ else :
26+ from . import macos_applescript
27+ return macos_applescript .getInfo ()
2328
2429
2530def get_current_window_windows () -> Optional [dict ]:
@@ -36,11 +41,11 @@ def get_current_window_windows() -> Optional[dict]:
3641 return {"app" : app , "title" : title }
3742
3843
39- def get_current_window () -> Optional [dict ]:
44+ def get_current_window (macos_strategy ) -> Optional [dict ]:
4045 if sys .platform .startswith ("linux" ):
4146 return get_current_window_linux ()
4247 elif sys .platform == "darwin" :
43- return get_current_window_macos ()
48+ return get_current_window_macos (macos_strategy )
4449 elif sys .platform in ["win32" , "cygwin" ]:
4550 return get_current_window_windows ()
4651 else :
0 commit comments