From b58942d6c6229c5dcac7c3914b1f9b161b8721bc Mon Sep 17 00:00:00 2001 From: Lucius Hu Date: Mon, 3 Jun 2019 03:38:30 -0400 Subject: [PATCH] Work for multiple GPUs now 1. Replace `\\"` with `\"`, otherwise awk warns `\"' is not a known regexp operator 2. Use the slot number of `lspci -mm` return value to determine whether two video cards are in different PCI slots, and therefore are two different GPUS. --- neofetch | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/neofetch b/neofetch index 3bd821fe..2ca10880 100755 --- a/neofetch +++ b/neofetch @@ -2135,9 +2135,9 @@ get_gpu() { case "$os" in "Linux") # Read GPUs into array. - gpu_cmd="$(lspci -mm | awk -F '\\"|\\" \\"|\\(' \ - '/"Display|"3D|"VGA/ {a[$0] = $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 " " $4} + END {for(i in a) {if(!seen[a[i]]++) print a[i]}}')" IFS=$'\n' read -d "" -ra gpus <<< "$gpu_cmd" # Remove duplicate Intel Graphics outputs.