Closed federicotorrielli closed 3 years ago
I really do not know why this is happening, I'll take a deep look into the code, for now just hide it using "macchina --hide mach". I'll keep you posted!
Can you try re-installing Macchina and see if that solves the issue. If that doesn't work, I'll have to inspect the code even more for potential bugs.
Ofc I tried reinstalling, but with no success. I am not really familiar with Rust but trying to read from that specific file even with this:
use std::io::Read;
pub fn main() {
//let name = fs::read_to_string("/sys/class/dmi/id/product_version").unwrap();
let mut name = std::fs::File::open("/sys/class/dmi/id/product_version").unwrap();
let mut contents = String::new();
name.read_to_string(&mut contents).unwrap();
println!("{}",contents);
}
It shows a blank output. So, for me, I think it has something to do with file read permissions.
As long as there's read permission to that file, Macchina should have no trouble reading it, could you provide me the output of ls -l /sys/class/dmi/id/product_version
?
Sure: .r--r--r-- root root 4.0 KB Thu Feb 11 17:31:31 2021 /sys/class/dmi/id/product_version
Aaaand, I just noticed that the file is really blank, as I stated before correcting on the EDIT. So the only way to get the product name is to get the product_name and not product_version. For some computers the product_version is blank, and for others is not, IDK what influences this behaviour.
The permissions look fine.
I have an idea that could possibly solve this issue once and for all.
I'll complement the current implementation with a condition, it'll work as follows:
The program will check the output of /sys/class/dmi/id/product_version
, if all goes well and the file is populated, it'll return the contents.
If it's empty, it'll construct the machine name using the output of the different files located in /sys/class/dmi/id
, and then return that newly constructed String.
Looks good, keep me updated.
I have to inform you about another issue that presented on a laptop running a distro based on arch (Arcolinux): the pkgs number is still 0, having pacman installed and everything. Are you, for some reason, checking the distro name or executing the command directly?
No, the program checks if /usr/bin/pacman
exists, and then runs pacman -Qq | wc -l
.
The way it checks for its existence is by checking the output of which pacman
.
Thanks for reporting these issues, I'll do my best to polish up the program before the next update.
dw. Oh, I understood. Pacman is installed on /usr/sbin/pacman on the majority of arch-based distribution out there, so ofc the pkgs are 0.
Got it! I'll keep you posted.
Edit: the package count issue has been solved, one down, one more to go!
Macchina v0.2.2 should fix the two issues you've encountered, try it out and tell me if anything goes wrong.
Edit: I'll update the AUR package if everything works as intended.
mach: Dell Inc. XPS
, it's good enough for me, but it's still not the whole line. Can you include the laptop name?
EDIT: pkgs are working fine.
Sure!
The reason I didn't include it is because each manufacturer sort of does their own thing when writing information about each model.
The output of /sys/class/dmi/id/product_family
for my machine is "IdeaPad S540-15IWL GTX"
The output of
/sys/class/dmi/id/product_family
for my machine is "IdeaPad S540-15IWL GTX"
Oh, I get it. OFC it's your choice to put it in or not. I would suggest to check the total length of the line and if it's more than N characters, you only pick what's necessary.
Latest commit appends product_name to product information. If more people report issues with product information I'll add that character length condition. Thanks for being patient with me :+1: and thanks a ton for your feedback!
Nice, thanks!
Hello, it's me again. As the title says, not every machine name is contained in "/sys/class/dmi/id/product_version". In fact, my Dell XPS 15 shows no model name in it. There is, however, a more generalized command that works on every Linux pc: to find my model I usually do
cat /sys/devices/virtual/dmi/id/product_name
(this excluding btw the Manufacturer, that is contained in/sys/devices/virtual/dmi/id/sys_vendor
).So, in the end, to print out the whole line in this way I usually do (on the fish shell):
echo (cat /sys/devices/virtual/dmi/id/sys_vendor) (cat /sys/devices/virtual/dmi/id/product_ name)
(or, on bash, echo $(cat /sys/devices/virtual/dmi/id/sys_vendor) $(cat /sys/devices/virtual/dmi/id/product_name))Tell me if this works for you because the current implementation doesn't.
EDIT: I just realized that it IS present in /sys/class/dmi/id/product_version, but macchina simply doesn't want it to print out on my terminal.