mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:42:09 +02:00
Chassis (Linux): uses /proc/device-tree/smbios if available
This commit is contained in:
@@ -16,14 +16,28 @@ const char* ffDetectChassis(FFChassisResult* result)
|
||||
{
|
||||
const char* typeStr = ffChassisTypeToString((uint32_t) ffStrbufToUInt(&result->type, 9999));
|
||||
if(typeStr)
|
||||
ffStrbufSetS(&result->type, typeStr);
|
||||
ffStrbufSetStatic(&result->type, typeStr);
|
||||
}
|
||||
}
|
||||
|
||||
else if(ffReadFileBuffer("/proc/device-tree/chassis-type", &result->type) && result->type.length > 0)
|
||||
else
|
||||
{
|
||||
ffStrbufTrimRight(&result->type, '\0');
|
||||
result->type.chars[0] = (char) toupper(result->type.chars[0]);
|
||||
// Available on Asahi Linux
|
||||
uint32_t chassisType = 0;
|
||||
if (ffReadFileData("/proc/device-tree/smbios/smbios/chassis/chassis-type", sizeof(chassisType), &chassisType)) // big endian
|
||||
{
|
||||
chassisType = __builtin_bswap32(chassisType);
|
||||
const char* typeStr = ffChassisTypeToString(chassisType);
|
||||
if(typeStr)
|
||||
ffStrbufSetStatic(&result->type, typeStr);
|
||||
|
||||
if(ffReadFileBuffer("/proc/device-tree/smbios/smbios/chassis/manufacturer", &result->vendor) && result->vendor.length > 0)
|
||||
ffStrbufTrimRight(&result->vendor, '\0');
|
||||
}
|
||||
else if(ffReadFileBuffer("/proc/device-tree/chassis-type", &result->type) && result->type.length > 0)
|
||||
{
|
||||
ffStrbufTrimRight(&result->type, '\0');
|
||||
result->type.chars[0] = (char) toupper(result->type.chars[0]);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user