mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:42:09 +02:00
Battery (Linux): fix temp detection for asahi
This commit is contained in:
@@ -89,7 +89,7 @@ static void parseBattery(FFstrbuf* dir, const char* id, FFBatteryOptions* option
|
||||
|
||||
FF_LIST_FOR_EACH(FFTempValue, value, *tempsResult)
|
||||
{
|
||||
if (ffStrbufEqualS(&value->name, id))
|
||||
if (ffStrbufEqualS(&value->deviceName, id))
|
||||
{
|
||||
result->temperature = value->value;
|
||||
break;
|
||||
|
||||
@@ -37,9 +37,24 @@ static bool parseHwmonDir(FFstrbuf* dir, FFTempValue* value)
|
||||
ffReadFileBuffer(dir->chars, &valueBuffer);
|
||||
}
|
||||
ffStrbufTrimRightSpace(&valueBuffer);
|
||||
ffStrbufSubstrBefore(dir, dirLength);
|
||||
if(valueBuffer.length)
|
||||
value->deviceClass = (uint32_t) strtoul(valueBuffer.chars, NULL, 16);
|
||||
|
||||
ffStrbufClear(&valueBuffer);
|
||||
ffStrbufEnsureFree(&valueBuffer, 64);
|
||||
ffStrbufAppendS(dir, "device");
|
||||
ssize_t linkLen = readlink(dir->chars, valueBuffer.chars, valueBuffer.allocated - 1);
|
||||
if (linkLen > 0)
|
||||
{
|
||||
valueBuffer.length = (uint32_t) linkLen;
|
||||
valueBuffer.chars[linkLen] = 0;
|
||||
ffStrbufSubstrAfterLastC(&valueBuffer, '/');
|
||||
ffStrbufInitMove(&value->deviceName, &valueBuffer);
|
||||
}
|
||||
else
|
||||
ffStrbufInit(&value->deviceName);
|
||||
|
||||
return value->name.length > 0 || value->deviceClass > 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
typedef struct FFTempValue
|
||||
{
|
||||
FFstrbuf name;
|
||||
FFstrbuf deviceName;
|
||||
uint32_t deviceClass;
|
||||
double value;
|
||||
} FFTempValue;
|
||||
|
||||
Reference in New Issue
Block a user