-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Idea] Get GPU information using pure Rust #2
Comments
Sorry for taking a while to respond. 😅 This is great! I had originally really wanted to read a file in
Interesting, I'm on Gentoo and I have it at Thank you for bringing this to my attention. It was genuinely irritating me that I'm using system commands to get the GPU model. |
Arch - |
I have asked users from other distros and these are some other locations where the file is located: Fedora 32 (Silverblue) - I don't know if it has anything to do with it, but the version of Slackware is 32-bit, as I was told. |
I've been using /sys/class/drm/card0/device/vendor and /sys/class/drm/card0/device/device on linux, this of course only gets the first gpu |
I wrote a quick toy program in rust to print the name of the gpu and it runs in 0.3ms on average, much faster than grepping lspci, I highly recommend implementing this, I can work on a pull request |
First of all, I love the initiative of the project. I started to learn Rust a few weeks ago and as my first project I set out to build a neofetch style tool, without realizing the existence of rsfetch, so I'd like to contribute here in what I can.
I saw that external commands are used to obtain information from the GPU, so I started to investigate how else could be done without depending on
grep
andlspci
.I found in the pciutils repository the following:
There are many possible places to search, depending on the kernel (or operating system). But in some cases it's a matter of reading a plain text file. In order not to make the issue too long, I recommend the first part of this article. As you can see in the article, it is possible to read the vendor identifier, device identifier and class identifier.
I quote again the previous repository, the following:
If we go through that website, we can corroborate that the GPU information (in addition to other devices that are not relevant) can be obtained from these ID's.
At first I thought that the
pci.ids
file should be downloaded regularly to keep it updated but, at least in Arch Linux, I found it in/usr/share/hwdata/pci.ids
.I'm not sure this is the best way to solve it, but I think it can work, without relying on system commands or external crates.
The text was updated successfully, but these errors were encountered: