Skip to content

Commit ff08b69

Browse files
authored
Fixed Retina detection for mirrorred monitors.
1 parent 7bf3f65 commit ff08b69

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

python_imagesearch/imagesearch.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,18 @@
33
import pyautogui
44
import random
55
import time
6+
import json
67
import platform
78
import subprocess
89
import os
910
import mss
1011

1112
is_retina = False
1213
if platform.system() == "Darwin":
13-
is_retina = subprocess.call("system_profiler SPDisplaysDataType | grep -i 'retina'", shell=True) == 0
14+
profiler = subprocess.run(["system_profiler", "SPDisplaysDataType", "-json"], stdout=subprocess.PIPE, check=True)
15+
monitors = json.loads(profiler.stdout)["SPDisplaysDataType"][0]["spdisplays_ndrvs"]
16+
main_monitor = next(iter(monitor for monitor in monitors if "yes" in monitor.get("spdisplays_main", "")))
17+
is_retina = "retina" in main_monitor.get("spdisplays_display_type", "")
1418

1519
'''
1620

0 commit comments

Comments
 (0)