Gpugetting fixed

This commit is contained in:
tr1x_em committed 2025-07-31 21:36:03 +05:30
1 parent 34c3011827
commit db00b3b2c7
1 file changed
+5 -26
+5 -26
View File
@@ -8,6 +8,7 @@ from fabric.widgets.box import Box
from widgets.wayland import WaylandWindow as Window from widgets.wayland import WaylandWindow as Window
from fabric.utils.helpers import exec_shell_command_async, get_relative_path from fabric.utils.helpers import exec_shell_command_async, get_relative_path
from gi.repository import Gtk, GdkPixbuf # type: ignore from gi.repository import Gtk, GdkPixbuf # type: ignore
import GPUtil
def read_dmi(field): def read_dmi(field):
@@ -18,33 +19,11 @@ def read_dmi(field):
return "Unknown" return "Unknown"
# TODO: Remove GPUtil dependency if not needed? (maybe?)
def get_gpu_name(): def get_gpu_name():
try: gpus = GPUtil.getGPUs()
output = ( if gpus:
subprocess.check_output( return gpus[0].name.strip()
"lspci -nn | grep -i 'VGA compatible controller'", shell=True, text=True
)
.strip()
.split("\n")
)
def clean(line):
matches = re.findall(r"\[(.*?)\]", line)
if len(matches) >= 2:
return matches[1].strip()
desc = line.split(":", 2)[-1]
return desc.replace("Corporation", "").strip()
for line in output:
if any(vendor in line.lower() for vendor in ["nvidia", "amd", "radeon"]):
return clean(line)
if output:
return clean(output[0])
return "Unknown GPU"
except Exception:
return "Unknown GPU"
class About(Gtk.Window): class About(Gtk.Window):