paleofetch

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 04a05ef0361fe4aa4ccb6ed6d857668d41a5ce65
parent 354f25035a65011562440274cd7005beca4bd8f7
Author: sam-barr <samfbarr@outlook.com>
Date:   Wed, 22 Apr 2020 19:37:55 -0500

Increased get_gpu accuracy

Diffstat:
Mpaleofetch.c | 12+++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/paleofetch.c b/paleofetch.c @@ -295,7 +295,8 @@ char *get_cpu() { char *get_gpu() { // inspired by https://github.com/pciutils/pciutils/edit/master/example.c - char *gpu = malloc(BUF_SIZE); + /* it seems that pci_lookup_name needs to be given a buffer, but I can't for the life of my figure out what its for */ + char buffer[BUF_SIZE], *gpu = malloc(BUF_SIZE); struct pci_access *pacc; struct pci_dev *dev; @@ -306,14 +307,15 @@ char *get_gpu() { while(dev != NULL) { pci_fill_info(dev, PCI_FILL_IDENT); - pci_lookup_name(pacc, gpu, BUF_SIZE, PCI_LOOKUP_DEVICE | PCI_LOOKUP_VENDOR, dev->vendor_id, dev->device_id); - /* as far as I know, this is the only way to check if its a graphics card */ - if(contains_substring(gpu, "Graphics", 8) >= 0) break; + if(strcmp("VGA compatible controller", pci_lookup_name(pacc, buffer, sizeof(buffer), PCI_LOOKUP_CLASS, dev->device_class)) == 0) { + strncpy(gpu, pci_lookup_name(pacc, buffer, sizeof(buffer), PCI_LOOKUP_DEVICE | PCI_LOOKUP_VENDOR, dev->vendor_id, dev->device_id), BUF_SIZE); + break; + } dev = dev->next; } - remove_substring(gpu, "Corporation ", 12); + remove_substring(gpu, "Corporation", 11); pci_cleanup(pacc); return gpu;