From d08ac108ed5699e28fa07dcc5aca290f3f6fe572 Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Thu, 31 Jul 2025 22:22:47 +0545 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactor(about):=20replace?= =?UTF-8?q?=20GPUtil=20with=20lspci=20to=20get=20GPU=20name?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/about.py | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/modules/about.py b/modules/about.py index 13a460f..c38e604 100644 --- a/modules/about.py +++ b/modules/about.py @@ -21,9 +21,31 @@ def read_dmi(field): # TODO: Remove GPUtil dependency if not needed? (maybe?) def get_gpu_name(): - gpus = GPUtil.getGPUs() - if gpus: - return gpus[0].name.strip() + output = subprocess.check_output("lspci", text=True) + gpus = [] + + for line in output.splitlines(): + if "VGA compatible controller" in line or "3D controller" in line: + parts = line.split(":", 2) + if len(parts) < 3: + continue + desc = parts[2].strip() + desc = re.sub(r"\(rev .*?\)", "", desc).strip() + + if "NVIDIA" in desc: + match = re.search(r"\[(.*?)\]", desc) + name = match.group(1) if match else desc + elif "Intel" in desc: + name = re.sub(r"Intel Corporation", "Intel", desc).strip() + elif "AMD" in desc or "ATI" in desc: + matches = re.findall(r"\[(.*?)\]", desc) + name = matches[1] if len(matches) > 1 else desc + else: + name = desc + + gpus.append((name)) + + return gpus[-1] class About(Gtk.Window):