diff --git a/bpytop.py b/bpytop.py index aceaa99..0ae6d08 100755 --- a/bpytop.py +++ b/bpytop.py @@ -2555,10 +2555,10 @@ class CpuCollector(Collector): cls.sensor_method = "" if SYSTEM == "MacOS": try: - if which("osx-cpu-temp") and subprocess.check_output("osx-cpu-temp", text=True).rstrip().endswith("°C"): + if which("coretemp") and subprocess.check_output(["coretemp", "-p"], text=True).strip().replace("-", "").isdigit(): + cls.sensor_method = "coretemp" + elif which("osx-cpu-temp") and subprocess.check_output("osx-cpu-temp", text=True).rstrip().endswith("°C"): cls.sensor_method = "osx-cpu-temp" - if which("coretemp") and subprocess.check_output("coretemp", text=True).split()[0].strip().replace("-", "").isdigit(): - cls.sensor_method += "+coretemp" except: pass elif hasattr(psutil, "sensors_temperatures"): try: @@ -2670,28 +2670,29 @@ class CpuCollector(Collector): else: try: - if cls.sensor_method.startswith("osx-cpu-temp") or cls.sensor_method.startswith("+coretemp"): - if cls.sensor_method.startswith("+coretemp"): - temp = max(0, round(float(subprocess.check_output(["coretemp", "-c 0", "-r 3"], text=True).split()[0].strip()))) + if cls.sensor_method == "coretemp": + temp = max(0, int(subprocess.check_output(["coretemp", "-p"], text=True).strip())) + cores = [max(0, int(x)) for x in subprocess.check_output("coretemp", text=True).split()] + if len(cores) < THREADS: + cls.cpu_temp[0].append(temp) + for n, t in enumerate(cores, start=1): + try: + cls.cpu_temp[n].append(t) + cls.cpu_temp[THREADS // 2 + n].append(t) + except IndexError: + break else: - temp = max(0, round(float(subprocess.check_output("osx-cpu-temp", text=True).strip()[:-2]))) - if cls.sensor_method.endswith("+coretemp"): - cores = [max(0, round(float(x))) for x in subprocess.check_output(["coretemp", "-r 3"], text=True).split()] - if len(cores) < THREADS: - cls.cpu_temp[0].append(temp) - for n, t in enumerate(cores, start=1): - try: - cls.cpu_temp[n].append(t) - cls.cpu_temp[THREADS // 2 + n].append(t) - except IndexError: - break - else: - cores.insert(0, temp) - for n, t in enumerate(cores): - try: - cls.cpu_temp[n].append(t) - except IndexError: - break + cores.insert(0, temp) + for n, t in enumerate(cores): + try: + cls.cpu_temp[n].append(t) + except IndexError: + break + if not cls.cpu_temp_high: + cls.cpu_temp_high = 85 + cls.cpu_temp_crit = 100 + elif cls.sensor_method == "osx-cpu-temp": + temp = max(0, round(float(subprocess.check_output("osx-cpu-temp", text=True).strip()[:-2]))) if not cls.cpu_temp_high: cls.cpu_temp_high = 85 cls.cpu_temp_crit = 100 @@ -2703,7 +2704,6 @@ class CpuCollector(Collector): except Exception as e: errlog.exception(f'{e}') cls.got_sensors = False - #CONFIG.check_temp = False CpuBox._calc_size() else: if not cores: @@ -2714,9 +2714,6 @@ class CpuCollector(Collector): for n in range(len(cls.cpu_temp)): del cls.cpu_temp[n][0] - - - @classmethod def _draw(cls): CpuBox._draw_fg()