dylanaraps / neofetch

🖼️ A command-line system information tool written in bash 3.2+
MIT License
21.56k stars 1.73k forks source link

Neofetch doesn't correctly show multiple GPUs #1206

Open alexreinking opened 5 years ago

alexreinking commented 5 years ago

Description

If you have multiple identical graphics cards installed in your system, neofetch will show only one of them. This is because the hash table in the awk command uses the vendor name + model for the key, rather than the pci address.

Relevant code reproduced below:

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]}}')"

Changing this to the following fixes the problem on my machine, though I don't know if it will work for others.

gpu_cmd="$(lspci -mm | awk -F '\\"|\\" \\"|\\(' \
                              '/"Display|"3D|"VGA/ {a[$1] = $3 " " $4} END {for(i in a)
                               {print a[i]}}')"

Maybe it would be best to make this feature configurable via an option? Allow users to include "duplicate" graphics cards?

Neofetch version

Version 3.4.0 via Ubuntu 18.04 package manager. Also affects master.

Screenshot

image

I would expect to see two lines, eg. GPU0 and GPU1 or a comma-separated list, or something similar. Something cool like "x2" or "SLI" (for Nvidia) would show that there were multiple copies of the same card and be more compact.

Config file

config.txt

Verbose log

neofetchlog.txt

konimex commented 5 years ago

What's the full content of lspci -mm?

alexreinking commented 5 years ago

@konimex -- Sorry for the delay. Here is the output:

lspci.txt

alexreinking commented 5 years ago

@konimex - did you get a chance to take a look at this?

konimex commented 5 years ago

I just finished my mid-terms so maybe I can get on this. But my awk-fu is quite weak, I'll see what I can do.

konimex commented 5 years ago

So far we have two options:

  1. Remove {if(!seen[a[i]]++) in our command, so the same GPU would be shown twice.
  2. Add x2 or x3 everytime there's a duplicate CPU, however I don't know if awk support this.

@dylanaraps, what do you think?

TheFeelTrain commented 5 years ago

Changing that line also worked for me on Arch Linux

dylanaraps commented 5 years ago

Will take a look at this shortly. Apologies.

e-leclercq commented 4 years ago

Since I don't have two GPUs, I used the following:

gpu_cmd="$(cat ./test/lspci.txt | awk -F '\"|\" \"|\\(' \
                                          '/"Display|"3D|"VGA/ {a[$0] = $1 " " $3 " " $4}
                                           END {for(i in a) {if(!seen[a[i]]++) print a[i]}}')"

On Arch Linux, using version 6.1.0, I got both GPUs in output; however, using version 3.4.0 and the lspci.txt gave just one GPU in the output.