diff --git a/main.py b/main.py index 0bfe099..a7d6b9d 100644 --- a/main.py +++ b/main.py @@ -1,5 +1,6 @@ import time #import subprocess +import os VERSION = "0.4.0" @@ -9,6 +10,7 @@ class Plugin: FAN_SPEEDS = [0, 1000, 2000, 3000, 4000, 5000, 6000] auto_fan = True + smt = None async def get_version(self) -> str: return VERSION @@ -17,6 +19,7 @@ class Plugin: # call from main_view.html with setCPUs(count, smt) async def set_cpus(self, count, smt=True) -> int: + self.smt = smt # print("Setting CPUs") if smt: count = min(int(count), self.CPU_COUNT) @@ -43,10 +46,15 @@ class Plugin: return online_count async def get_smt(self) -> bool: - for cpu in range(1, self.CPU_COUNT, 2): - if (not status_cpu(cpu)) and status_cpu(cpu+1): - return False - return True + if self.smt is None: + for cpu in range(1, self.CPU_COUNT, 2): + if (not status_cpu(cpu)) and status_cpu(cpu+1): + self.smt = False + return False + self.smt = True + return True + else: + return self.smt async def set_boost(self, enabled: bool) -> bool: write_to_sys("/sys/devices/system/cpu/cpufreq/boost", int(enabled)) @@ -124,6 +132,9 @@ class Plugin: return i return len(self.FAN_SPEEDS)-1 # any higher value is considered as highest manual setting + async def fantastic_installed(self) -> bool: + return os.path.exists("/home/deck/homebrew/plugins/Fantastic") + # Battery stuff async def get_charge_now(self) -> int: diff --git a/main_view.html b/main_view.html index 594a11e..d4259c4 100644 --- a/main_view.html +++ b/main_view.html @@ -54,6 +54,10 @@ return call_plugin_method("get_fan_tick", {}); } + function getFantastic() { + return call_plugin_method("fantastic_installed", {}); + } + function getChargeNow() { return call_plugin_method("get_charge_now", {}); } @@ -75,7 +79,15 @@ selectNotch("cpuThreadsNotch", await getCPUs() - 1, 8); selectNotch("frequencyNotch", await getMaxBoost(), 3); await onReadyGPU(); - selectNotch("fanNotch", await getFanTick(), 8); + let isFantasticInstalled = await getFantastic(); + if (isFantasticInstalled) { + // Don't fight with Fantastic + let fanRoot = document.getElementById("fanRoot"); + fanRoot.style.visibility = "hidden"; + fanRoot.style.height = "0px"; + } else { + selectNotch("fanNotch", await getFanTick(), 8); + } await updateBatteryStats(); // this is unimportant; always do it last await updateVersion(); @@ -430,7 +442,7 @@ -
+
Fan RPM