diff --git a/OpenHardwareMonitorLib.dll b/OpenHardwareMonitorLib.dll new file mode 100644 index 0000000..ea3c3bd Binary files /dev/null and b/OpenHardwareMonitorLib.dll differ diff --git a/liquidctl_helper_interface.py b/liquidctl_helper_interface.py new file mode 100644 index 0000000..8a35616 --- /dev/null +++ b/liquidctl_helper_interface.py @@ -0,0 +1,48 @@ +from abc import ABC, abstractmethod, abstractproperty + +class LiquidCTL_Helper_Interface(ABC): + @property + @abstractmethod + def device_name(self) -> str: + pass + + @property + @abstractmethod + def device_temp(self) -> float: + pass + + @property + @abstractmethod + def device_fanSpeed(self) -> float: + pass + + @property + @abstractmethod + def device_pumpSpeed(self) -> float: + pass + + @property + @abstractmethod + def device_fwVers(self) -> str: + pass + + @property + @abstractmethod + def devices(self) -> None: + pass + + @abstractmethod + def ForceInit(self) -> None: + pass + + @abstractmethod + def TestConnectionState(self) -> None: + pass + + @abstractmethod + def Update(self) -> None: + pass + + @abstractmethod + def SetFanSpeed(self, speed) -> None: + pass \ No newline at end of file diff --git a/LiquidCTL_Helper_Linux.py b/liquidctl_helper_linux.py similarity index 87% rename from LiquidCTL_Helper_Linux.py rename to liquidctl_helper_linux.py index 2e5322a..da538c6 100644 --- a/LiquidCTL_Helper_Linux.py +++ b/liquidctl_helper_linux.py @@ -1,7 +1,8 @@ import subprocess import re +from liquidctl_helper_interface import LiquidCTL_Helper_Interface -class LiquidCTL_Helper(): +class LiquidCTL_Helper(LiquidCTL_Helper_Interface): device_name: str = "" device_temp = 0 device_fanSpeed = 0 @@ -29,4 +30,4 @@ class LiquidCTL_Helper(): def SetFanSpeed(self, speed): - NotImplemented + NotImplemented \ No newline at end of file diff --git a/LiquidCTL_Helper_Windows.py b/liquidctl_helper_windows.py similarity index 93% rename from LiquidCTL_Helper_Windows.py rename to liquidctl_helper_windows.py index c06c526..5f0b5c5 100644 --- a/LiquidCTL_Helper_Windows.py +++ b/liquidctl_helper_windows.py @@ -1,6 +1,7 @@ from liquidctl import find_liquidctl_devices, cli # type: ignore +from liquidctl_helper_interface import LiquidCTL_Helper_Interface -class LiquidCTL_Helper(): +class LiquidCTL_Helper(LiquidCTL_Helper_Interface): device_name = None device_temp = 0 device_fanSpeed = 0 diff --git a/main.pyw b/main.pyw index de27917..017cfb6 100644 --- a/main.pyw +++ b/main.pyw @@ -16,14 +16,16 @@ import common from MessageHandler import MessageHandler ## Platform Imports ######################################### import globals -from sys_vitals_helper import SysVitals_Helper, Component +from vitals_helper import Component from styles import Labels if globals.os == "Windows": - from LiquidCTL_Helper_Windows import LiquidCTL_Helper + from liquidctl_helper_windows import LiquidCTL_Helper + from vitals_helper import VitalsHelperWindows as svh import win32mica # type: ignore import darkdetect # type: ignore elif globals.os == "Linux": - from LiquidCTL_Helper_Linux import LiquidCTL_Helper + from liquidctl_helper_linux import LiquidCTL_Helper + from vitals_helper import VitalsHelperLinux as svh @@ -36,7 +38,7 @@ class MainWindow(QMainWindow): self.setFixedSize(450, 700) self.lctl = lctl - self.svh = SysVitals_Helper() + self.svh = svh() # Widgets ########################################## self.lbl_device_name = Labels.MainLabel() @@ -122,10 +124,10 @@ class MainWindow(QMainWindow): self.lbl_value_prg_cpu_temp.setText( self.min_max_cur_cpu_temp.builder( - self.svh.GetTemps(Component.CPU_AMD), "°C")) + self.svh.get_temps(Component.lin_cpu_amd), "°C")) self.prg_cpu_temp.setValue( - self.svh.GetTemps(Component.CPU_AMD)) + self.svh.get_temps(Component.lin_cpu_amd)) self.lbl_device_name.setText( self.lctl.device_name) @@ -154,10 +156,6 @@ class MainWindow(QMainWindow): if self.lctl.device_fwVers is not None: self.lbl_fwvers.setText(f"Firmware: v{self.lctl.device_fwVers}") - # print(f"CPU: {self.svh.GetTemps(Component.CPU_AMD)}°C") - # print(f"GPU: {self.svh.GetTemps(Component.GPU_AMD)}°C") - # print(f"MOBO: {self.svh.GetTemps(Component.MOBO_ASUS)}°C") - def main(): """ Initialize application and setup window parameters. """ @@ -169,9 +167,9 @@ def main(): icon = QIcon(":/icons/LiquidGUI.ico") if darkdetect.isDark(): - win32mica.ApplyMica(window.winId(), win32mica.MICAMODE.DARK) + win32mica.ApplyMica(window.winId(), win32mica.MicaTheme.DARK) elif darkdetect.isLight(): - win32mica.ApplyMica(window.winId(), win32mica.MICAMODE.LIGHT) + win32mica.ApplyMica(window.winId(), win32mica.MicaTheme.LIGHT) elif globals.os == "Linux": app.setDesktopFileName("LiquidGUI") diff --git a/sys_vitals_helper.py b/sys_vitals_helper.py deleted file mode 100644 index 8c29e89..0000000 --- a/sys_vitals_helper.py +++ /dev/null @@ -1,17 +0,0 @@ -from enum import Enum -import psutil - -class Component(Enum): - CPU_AMD = ("k10temp", "Tctl") - GPU_AMD = ("amdgpu", "edge") - MOBO_ASUS = ("asus_wmi_sensors", "Motherboard Temperature") - -class SysVitals_Helper(): - - def GetTemps(self, component: Component): - temps = psutil.sensors_temperatures() - - if component.value[0] in temps: - for entry in temps[component.value[0]]: - if entry.label == component.value[1]: - return round(entry.current, 2) \ No newline at end of file diff --git a/vitals_helper.py b/vitals_helper.py new file mode 100644 index 0000000..03867b4 --- /dev/null +++ b/vitals_helper.py @@ -0,0 +1,33 @@ +from enum import Enum +from abc import ABC, abstractmethod +import psutil +import pythonnet +import os + +class Component(Enum): + lin_cpu_amd = ("k10temp", "Tctl") + lin_gpu_amd = ("amdgpu", "edge") + lin_mobo_asus = ("asus_wmi_sensors", "Motherboard Temperature") + + +class VitalsHelperInterface(ABC): + @abstractmethod + def get_temps(self, component: Component): + """ Return Temperatures """ + pass + +class VitalsHelperLinux(VitalsHelperInterface): + def get_temps(self, component: Component): + temps = psutil.sensors_temperatures() + + if component.value[0] in temps: + for entry in temps[component.value[0]]: + if entry.label == component.value[1]: + return round(entry.current, 2) + +class VitalsHelperWindows(VitalsHelperInterface): + def __init__(self): + print(f"{self.__class__.__name__} is not Implemented") + + def get_temps(self, component: Component): + return 0 \ No newline at end of file