File tree Expand file tree Collapse file tree 2 files changed +14
-18
lines changed
Expand file tree Collapse file tree 2 files changed +14
-18
lines changed Original file line number Diff line number Diff line change @@ -17,12 +17,9 @@ def get_current_window_linux() -> Optional[dict]:
1717
1818
1919def get_current_window_macos () -> Optional [dict ]:
20+ # TODO should we use unknown when the title is blank like the other platforms?
2021 from . import macos
21- info = macos .getInfo ()
22- app = macos .getApp (info )
23- title = macos .getTitle (info )
24-
25- return {"title" : title , "appname" : app }
22+ return macos .getInfo ()
2623
2724
2825def get_current_window_windows () -> Optional [dict ]:
Original file line number Diff line number Diff line change 11import subprocess
2- from subprocess import PIPE
32import os
3+ import json
4+ import logging
45
6+ logger = logging .getLogger (__name__ )
57
68def getInfo () -> str :
7- cmd = ["osascript" , os .path .join (os .path .dirname (os .path .realpath (__file__ )), "printAppTitle.scpt" )]
8- p = subprocess .run (cmd , stdout = PIPE )
9- return str (p .stdout , "utf8" ).strip ()
10-
11-
12- def getApp (info : str ) -> str :
13- return info .split ('","' )[0 ][1 :]
14-
15-
16- def getTitle (info : str ) -> str :
17- return info .split ('","' )[1 ][:- 1 ]
18-
9+ cmd = [os .path .join (os .path .dirname (os .path .realpath (__file__ )), "printAppStatus.jxa" )]
10+ p = subprocess .run (cmd , stdout = subprocess .PIPE )
11+ result = str (p .stdout , "utf8" ).strip ()
12+
13+ try :
14+ return json .loads (result )
15+ except JSONDecodeError as e :
16+ logger .warn ("invalid JSON encountered {result}" )
17+ return {}
1918
2019def background_ensure_permissions () -> None :
2120 from multiprocessing import Process
You can’t perform that action at this time.
0 commit comments