diff --git a/LiquidCTL_Helper_Linux.py b/LiquidCTL_Helper_Linux.py new file mode 100644 index 0000000..1e25952 --- /dev/null +++ b/LiquidCTL_Helper_Linux.py @@ -0,0 +1,32 @@ +import subprocess +import re + +class LiquidCTL_Helper(): + device_name = None + device_temp = 0 + device_fanSpeed = 0 + device_pumpSpeed = 0 + device_fwVers = None + + devices = None + + def ForceInit(self): + NotImplemented + + def TestConnectionState(self): + output = subprocess.run(["liquidctl", "status"], stdout=subprocess.PIPE, universal_newlines=True) + if len(output.stdout) > 0: + return False + else: + return True + + def Update(self): + output = subprocess.run(["liquidctl", "status"], stdout=subprocess.PIPE, universal_newlines=True) + self.device_name = str(re.search(r'^[^\n]*', output.stdout).group(0)) + self.device_temp = float(re.search(r'Liquid temperature\s+(\d+\.?\d*)', output.stdout).group(1)) + self.device_fanSpeed = int(re.search(r'Fan speed\s+(\d+)', output.stdout).group(1)) + self.device_pumpSpeed = int(re.search(r'Pump speed\s+(\d+)', output.stdout).group(1)) + + + def SetFanSpeed(self, speed): + NotImplemented diff --git a/LiquidCTL_Helper.py b/LiquidCTL_Helper_Windows.py similarity index 100% rename from LiquidCTL_Helper.py rename to LiquidCTL_Helper_Windows.py diff --git a/globals.py b/globals.py new file mode 100644 index 0000000..8bb2d0c --- /dev/null +++ b/globals.py @@ -0,0 +1,8 @@ +import platform + +os = None +_platform = platform.platform() +if _platform.startswith("Linux"): + os = "Linux" +elif _platform.startswith("Windows"): + os = "Windows" \ No newline at end of file diff --git a/main.pyw b/main.pyw index 48e60c6..f29a79d 100644 --- a/main.pyw +++ b/main.pyw @@ -1,24 +1,27 @@ # External Dependencies import sys -import win32mica from PySide6.QtWidgets import QApplication, QMainWindow, QWidget, QVBoxLayout, QLabel, QProgressBar, QPushButton from PySide6.QtCore import Qt, QTimer, QThreadPool from PySide6.QtGui import QFont, QIcon import darkdetect # Internal Imports -from LiquidCTL_Helper import LiquidCTL_Helper +import common +import globals from MessageHandler import MessageHandler from styles import Labels -import common -import resources, pkg_resources.extern - +import resources +if globals.os == "Windows": + from LiquidCTL_Helper_Windows import LiquidCTL_Helper + import win32mica +elif globals.os == "Linux": + from LiquidCTL_Helper_Linux import LiquidCTL_Helper class MainWindow(QMainWindow): """ Main application window. """ def __init__(self, lctl): super(MainWindow, self).__init__() - self.setWindowTitle("LiquidGUI (v.1.1.3.0)") + self.setWindowTitle("LiquidGUI (v.1.2.0.0) DEV") self.setFixedSize(450, 500) self.lctl = lctl @@ -117,17 +120,19 @@ def main(): window = MainWindow(LiquidCTL_Helper()) window.setWindowIcon(icon) - window.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground) + if globals.platform == "Windows": + window.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground) # Show error and quit app if no devices are found if window.lctl.TestConnectionState(): MessageHandler().ShowNoDevicesFoundError() sys.exit(1) else: - if darkdetect.isDark(): - win32mica.ApplyMica(window.winId(), win32mica.MICAMODE.DARK) - elif darkdetect.isLight(): - win32mica.ApplyMica(window.winId(), win32mica.MICAMODE.LIGHT) + if globals.platform == "Windows": + if darkdetect.isDark(): + win32mica.ApplyMica(window.winId(), win32mica.MICAMODE.DARK) + elif darkdetect.isLight(): + win32mica.ApplyMica(window.winId(), win32mica.MICAMODE.LIGHT) window.show() app.exec()