From 219714c86ef298102ce7eb7bce1124ac9df9df68 Mon Sep 17 00:00:00 2001 From: Guanzhong Chen Date: Fri, 11 Jun 2021 03:39:07 -0400 Subject: [PATCH] Show GPU subsystem name if possible. Fixes #1490 (#1648) After this change, if a subsystem name exists for a GPU, we display that name instead of the device name. This should fix the issue mentioned in #1490. For example, a card that would be shown as: GPU: AMD ATI Radeon RX 470/480/570/570X/580/580X/590 before will now be shown as: GPU: AMD ATI Radeon RX 480 4GB This fallback logic is implemented in the `awk` command. Additionally, the PCI address is now stripped from the awk output because it never is desirable to print it. It is, however, still kept internally in `awk` to distinguish multiple cards of the same model. --- neofetch | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/neofetch b/neofetch index 28900c8f..f93e1fea 100755 --- a/neofetch +++ b/neofetch @@ -2449,9 +2449,17 @@ get_gpu() { case $os in "Linux") # Read GPUs into array. - gpu_cmd="$(lspci -mm | awk -F '\"|\" \"|\\(' \ - '/"Display|"3D|"VGA/ {a[$0] = $1 " " $3 " " $4} - END {for(i in a) {if(!seen[a[i]]++) print a[i]}}')" + gpu_cmd="$(lspci -mm | + awk -F '\"|\" \"|\\(' \ + '/"Display|"3D|"VGA/ { + a[$0] = $1 " " $3 " " ($7 ~ /^$|^Device [[:xdigit:]]+$/ ? $4 : $7) + } + END { for (i in a) { + if (!seen[a[i]]++) { + sub("^[^ ]+ ", "", a[i]); + print a[i] + } + }}')" IFS=$'\n' read -d "" -ra gpus <<< "$gpu_cmd" # Remove duplicate Intel Graphics outputs.