From bc629d12b276861e7c416343a9493975e5aad8fc Mon Sep 17 00:00:00 2001 From: Ognyan Kulev Date: Sun, 14 Dec 2025 12:44:30 +0200 Subject: [PATCH] Remove 'AMD' prefix and 'Graphics' suffix. --- glances/plugins/gpu/cards/amd.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/glances/plugins/gpu/cards/amd.py b/glances/plugins/gpu/cards/amd.py index d548cdf2..8f031137 100644 --- a/glances/plugins/gpu/cards/amd.py +++ b/glances/plugins/gpu/cards/amd.py @@ -11,7 +11,6 @@ The class grabs the stats from the /sys/class/drm/ directory. See: https://wiki.archlinux.org/title/AMDGPU#Manually -amdgpu.ids source: https://cgit.freedesktop.org/drm/libdrm/tree/data/amdgpu.ids """ # Example @@ -45,7 +44,7 @@ import functools DRM_ROOT_FOLDER: str = '/sys/class/drm' CARD_REGEX: str = r"^card\d$" DEVICE_FOLDER: str = 'device' -AMDGPU_IDS: str = '/usr/share/libdrm/amdgpu.ids' +AMDGPU_IDS_FILE: str = '/usr/share/libdrm/amdgpu.ids' PCI_DEVICE_ID: str = 'device' PCI_REVISION_ID: str = 'revision' GPU_PROC_PERCENT: str = 'gpu_busy_percent' @@ -123,18 +122,19 @@ def read_file(*path_segments: str) -> Optional[str]: def get_device_name(device_folder: str) -> str: """Return the GPU name.""" + # Table source: https://cgit.freedesktop.org/drm/libdrm/tree/data/amdgpu.ids device_id = read_file(device_folder, PCI_DEVICE_ID) revision_id = read_file(device_folder, PCI_REVISION_ID) - amdgpu_ids = read_file(AMDGPU_IDS) + amdgpu_ids = read_file(AMDGPU_IDS_FILE) if device_id and revision_id and amdgpu_ids: # Strip leading "0x" and convert to uppercase hexadecimal device_id = device_id[2:].upper() revision_id = revision_id[2:].upper() # Syntax: # device_id, revision_id, product_name <-- single tab after comma - pattern = re.compile(f'^{device_id},\\s{revision_id},\\s(.+)$', re.MULTILINE) + pattern = re.compile(f'^{device_id},\\s{revision_id},\\s(?P.+)$', re.MULTILINE) if match := pattern.search(amdgpu_ids): - return match.group(1) + return match.group('product_name').removeprefix('AMD ').removesuffix(' Graphics') return 'AMD GPU'