From 2226ebbe69151d44b9f2e2994e28960989169812 Mon Sep 17 00:00:00 2001 From: Dunestorm Date: Mon, 27 Jan 2025 00:17:44 +0000 Subject: [PATCH] LiquidGUI [1.3.0.0] - Initial psutil support for system vitals. --- LiquidCTL_Helper_Linux.py | 2 +- LiquidCTL_Helper_Windows.py | 2 +- main.pyw | 30 ++++++++++++++++++++++++++---- sys_vitals_helper.py | 17 +++++++++++++++++ 4 files changed, 45 insertions(+), 6 deletions(-) create mode 100644 sys_vitals_helper.py diff --git a/LiquidCTL_Helper_Linux.py b/LiquidCTL_Helper_Linux.py index 1e25952..2e5322a 100644 --- a/LiquidCTL_Helper_Linux.py +++ b/LiquidCTL_Helper_Linux.py @@ -2,7 +2,7 @@ import subprocess import re class LiquidCTL_Helper(): - device_name = None + device_name: str = "" device_temp = 0 device_fanSpeed = 0 device_pumpSpeed = 0 diff --git a/LiquidCTL_Helper_Windows.py b/LiquidCTL_Helper_Windows.py index 1e6cbe1..c06c526 100644 --- a/LiquidCTL_Helper_Windows.py +++ b/LiquidCTL_Helper_Windows.py @@ -1,4 +1,4 @@ -from liquidctl import find_liquidctl_devices, cli +from liquidctl import find_liquidctl_devices, cli # type: ignore class LiquidCTL_Helper(): device_name = None diff --git a/main.pyw b/main.pyw index d62f4ac..2e5aa7e 100644 --- a/main.pyw +++ b/main.pyw @@ -16,15 +16,17 @@ import common from MessageHandler import MessageHandler ## Platform Imports ######################################### import globals +from sys_vitals_helper import SysVitals_Helper if globals.os == "Windows": from LiquidCTL_Helper_Windows import LiquidCTL_Helper from styles import Labels_Windows as Labels - import win32mica - import darkdetect + import win32mica # type: ignore + import darkdetect # type: ignore elif globals.os == "Linux": from LiquidCTL_Helper_Linux import LiquidCTL_Helper from styles import Labels_Linux as Labels from pathlib import Path + from sys_vitals_helper import SysVitals_Helper, Component class MainWindow(QMainWindow): @@ -32,10 +34,11 @@ class MainWindow(QMainWindow): def __init__(self, lctl): super(MainWindow, self).__init__() - self.setWindowTitle("LiquidGUI (v.1.2.0.0)") - self.setFixedSize(450, 500) + self.setWindowTitle("LiquidGUI (v.1.3.0.0) DEV") + self.setFixedSize(450, 700) self.lctl = lctl + self.svh = SysVitals_Helper() # Widgets ########################################## self.lbl_device_name = Labels.MainLabel() @@ -60,6 +63,14 @@ class MainWindow(QMainWindow): minimum=1900, maximum=2700) self.lbl_value_prg_pumpspeed = Labels.SubLabelValue() + + self.lbl_cpu_temp = Labels.SubLabel(value="🔳 CPU Temp:") + self.min_max_cur_cpu_temp = common.MinMaxCurrent() + self.prg_cpu_temp = QProgressBar(textVisible=False, + minimum=0, + maximum=105) + self.lbl_value_prg_cpu_temp = Labels.SubLabelValue() + self.btn_reset_min_max = QPushButton("Reset Min/Max") self.btn_reset_min_max.clicked.connect(self.on_reset_min_max) @@ -78,6 +89,9 @@ class MainWindow(QMainWindow): layout.addWidget(self.lbl_pumpspeed) layout.addWidget(self.prg_pumpspeed) layout.addWidget(self.lbl_value_prg_pumpspeed) + layout.addWidget(self.lbl_cpu_temp) + layout.addWidget(self.prg_cpu_temp) + layout.addWidget(self.lbl_value_prg_cpu_temp) layout.addWidget(self.lbl_fwvers) layout.addWidget(self.btn_reset_min_max) @@ -102,6 +116,7 @@ class MainWindow(QMainWindow): self.min_max_cur_temp = common.MinMaxCurrent() self.min_max_cur_fanspeed = common.MinMaxCurrent() self.min_max_cur_pumpspeed = common.MinMaxCurrent() + self.min_max_cur_cpu_temp = common.MinMaxCurrent() self.timer.start() def update_widgets(self): @@ -121,6 +136,13 @@ class MainWindow(QMainWindow): self.lctl.device_pumpSpeed, " rpm")) if self.lctl.device_fwVers is not None: self.lbl_fwvers.setText(f"Firmware: v{self.lctl.device_fwVers}") + self.prg_cpu_temp.setValue(self.svh.GetTemps(Component.CPU_AMD)) + self.lbl_value_prg_cpu_temp.setText( + self.min_max_cur_cpu_temp.builder( + self.svh.GetTemps(Component.CPU_AMD), "°C")) + # 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(): diff --git a/sys_vitals_helper.py b/sys_vitals_helper.py new file mode 100644 index 0000000..a6cd470 --- /dev/null +++ b/sys_vitals_helper.py @@ -0,0 +1,17 @@ +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 entry.current \ No newline at end of file