diff options
Diffstat (limited to 'raveos-welcome/raveos_welcome.py')
| -rw-r--r-- | raveos-welcome/raveos_welcome.py | 143 |
1 files changed, 128 insertions, 15 deletions
diff --git a/raveos-welcome/raveos_welcome.py b/raveos-welcome/raveos_welcome.py index ec1e2a8..7d1d9e6 100644 --- a/raveos-welcome/raveos_welcome.py +++ b/raveos-welcome/raveos_welcome.py @@ -1436,18 +1436,133 @@ class HyprlandPage(QWidget): # ─── GPU Detection ──────────────────────────────────────────────────────────── -def _detect_gpu() -> str: +def _detect_gpu() -> tuple[str, str]: + gpu_type = "other" + labels = [] + has_nvidia = False + has_amd = False + has_intel = False + try: out = subprocess.check_output( - ["lspci"], stderr=subprocess.DEVNULL - ).decode().lower() - if "amd" in out or "radeon" in out: - return "amd" - if "nvidia" in out: - return "nvidia" + ["lspci", "-v"], stderr=subprocess.DEVNULL + ).decode() + + current_block = [] + gpu_blocks = [] + for line in out.splitlines(): + if line and not line.startswith(("\t", " ")): + if current_block: + first = current_block[0] + if any(k in first for k in ("VGA compatible controller", "3D controller", "Display controller")): + gpu_blocks.append(current_block) + current_block = [line] + else: + current_block.append(line) + if current_block: + first = current_block[0] + if any(k in first for k in ("VGA compatible controller", "3D controller", "Display controller")): + gpu_blocks.append(current_block) + + import re + for block in gpu_blocks: + header = block[0] + subsystem = "" + for sub in block[1:]: + if "Subsystem:" in sub: + subsystem = sub.split("Subsystem:", 1)[1].strip() + break + + lower_header = header.lower() + lower_sub = subsystem.lower() + + model_info = header.split(":", 2)[-1].strip() + if " (rev " in model_info: + model_info = model_info.split(" (rev ")[0].strip() + + vendor_brand = "" + if "evga" in lower_sub or "evga" in lower_header: + vendor_brand = "EVGA" + elif "asus" in lower_sub or "asustek" in lower_sub: + vendor_brand = "ASUS" + elif "msi" in lower_sub or "micro-star" in lower_sub: + vendor_brand = "MSI" + elif "gigabyte" in lower_sub: + vendor_brand = "Gigabyte" + elif "sapphire" in lower_sub: + vendor_brand = "Sapphire" + elif "powercolor" in lower_sub: + vendor_brand = "PowerColor" + elif "xfx" in lower_sub: + vendor_brand = "XFX" + elif "zotac" in lower_sub: + vendor_brand = "Zotac" + + clean_name = model_info + for rep in ("Advanced Micro Devices, Inc. [AMD/ATI]", "Advanced Micro Devices, Inc.", "AMD/ATI"): + clean_name = clean_name.replace(rep, "AMD").strip() + for rep in ("NVIDIA Corporation", "Nvidia Corporation"): + clean_name = clean_name.replace(rep, "Nvidia").strip() + for rep in ("Intel Corporation",): + clean_name = clean_name.replace(rep, "Intel").strip() + + bracket_match = re.search(r'\[(.*?)\]', clean_name) + if bracket_match: + extracted = bracket_match.group(1) + prefix = "" + if "nvidia" in lower_header and "geforce" not in extracted.lower(): + prefix = "Nvidia " + elif "amd" in lower_header and "radeon" not in extracted.lower(): + prefix = "AMD " + elif "intel" in lower_header and "intel" not in extracted.lower(): + prefix = "Intel " + clean_name = f"{prefix}{extracted}" + + if "intel" in lower_header: + has_intel = True + if "igpu" not in clean_name.lower() and "arc" not in clean_name.lower(): + clean_name += " (iGPU)" + elif "nvidia" in lower_header: + has_nvidia = True + elif "amd" in lower_header or "radeon" in lower_header: + has_amd = True + + if vendor_brand and vendor_brand.lower() not in clean_name.lower(): + clean_name += f" ({vendor_brand})" + + labels.append(clean_name) + except Exception: pass - return "other" + + if not labels: + try: + out = subprocess.check_output( + ["lspci"], stderr=subprocess.DEVNULL + ).decode().lower() + if "nvidia" in out: + has_nvidia = True + labels.append("Nvidia") + if "amd" in out or "radeon" in out: + has_amd = True + labels.append("AMD") + if "intel" in out: + has_intel = True + labels.append("Intel (iGPU)") + except Exception: + pass + + if has_nvidia: + gpu_type = "nvidia" + elif has_amd: + gpu_type = "amd" + elif has_intel: + gpu_type = "intel" + else: + gpu_type = "other" + + gpu_label = " + ".join(labels) if labels else "Ismeretlen" + return gpu_type, gpu_label # ─── Page 3: Optimize ────────────────────────────────────────────────────────── @@ -1481,7 +1596,7 @@ QCheckBox:disabled {{ class OptimizePage(QWidget): def __init__(self): super().__init__() - self._gpu = _detect_gpu() + self._gpu_type, self._gpu_label = _detect_gpu() self._checks = {} self._hints = {} self._proc = None @@ -1504,8 +1619,7 @@ class OptimizePage(QWidget): vlay.setSpacing(4) # --- Gaming optimization --- - gpu_name = {"amd": "AMD", "nvidia": "Nvidia"}.get(self._gpu, "Ismeretlen") - self.sec1 = QLabel(_t("opt_gaming", gpu=gpu_name)) + self.sec1 = QLabel(_t("opt_gaming", gpu=self._gpu_label)) self.sec1.setObjectName("section_title") vlay.addWidget(self.sec1) vlay.addSpacing(4) @@ -1524,14 +1638,14 @@ class OptimizePage(QWidget): self._amd_checks = {} self._nvidia_checks = {} - if self._gpu == "nvidia": + if self._gpu_type == "nvidia": cb = self._add_check(vlay, "nvidia_perf", _t("opt_nvidia_perf"), _t("opt_nvidia_perf_desc"), default=True) self._nvidia_checks["nvidia_perf"] = ("opt_nvidia_perf", "opt_nvidia_perf_desc", cb) - if self._gpu == "amd": + if self._gpu_type == "amd": amd_opts = [ ("gpu_profile", "opt_gpu_profile", "opt_gpu_profile_desc"), ("amd_overdrive", "opt_amd_overdrive", "opt_amd_overdrive_desc"), @@ -1563,8 +1677,7 @@ class OptimizePage(QWidget): lay.addWidget(self.apply_btn, alignment=Qt.AlignmentFlag.AlignRight) def retranslate(self): - gpu_name = {"amd": "AMD", "nvidia": "Nvidia"}.get(self._gpu, "Ismeretlen") - self.sec1.setText(_t("opt_gaming", gpu=gpu_name)) + self.sec1.setText(_t("opt_gaming", gpu=self._gpu_label)) self.apply_btn.setText(_t("opt_apply")) for key, (lk, dk, cb) in self._common_checks.items(): cb.setText(_t(lk)) |