mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2025-02-20 11:43:27 +08:00
Temps (Windows): dirty support
Note: https://stackoverflow.com/a/17083409
This commit is contained in:
parent
c570c5bf97
commit
7f15f91bd3
@ -519,6 +519,7 @@ elseif(WIN32)
|
||||
src/detection/swap/swap_windows.cpp
|
||||
src/detection/terminalfont/terminalfont_windows.c
|
||||
src/detection/terminalshell/terminalshell_windows.cpp
|
||||
src/detection/temps/temps_windows.cpp
|
||||
src/detection/uptime/uptime_windows.c
|
||||
src/detection/users/users_windows.c
|
||||
src/detection/wifi/wifi_windows.c
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "cpu.h"
|
||||
#include "detection/temps/temps_windows.h"
|
||||
#include "util/windows/registry.h"
|
||||
#include "util/mallocHelper.h"
|
||||
|
||||
@ -46,4 +47,7 @@ void ffDetectCPUImpl(const FFinstance* instance, FFCPUResult* cpu)
|
||||
|
||||
ffRegReadStrbuf(hKey, L"ProcessorNameString", &cpu->name, NULL);
|
||||
ffRegReadStrbuf(hKey, L"VendorIdentifier", &cpu->vendor, NULL);
|
||||
|
||||
if(instance->config.cpuTemp)
|
||||
ffDetectSmbiosTemp(&cpu->temperature, NULL);
|
||||
}
|
||||
|
25
src/detection/temps/temps_windows.cpp
Normal file
25
src/detection/temps/temps_windows.cpp
Normal file
@ -0,0 +1,25 @@
|
||||
extern "C"
|
||||
{
|
||||
#include "temps_windows.h"
|
||||
}
|
||||
#include "util/windows/wmi.hpp"
|
||||
|
||||
extern "C"
|
||||
const char* ffDetectSmbiosTemp(double* current, double* critical)
|
||||
{
|
||||
// Requires Administrator priviledges
|
||||
// https://wutils.com/wmi/root/wmi/msacpi_thermalzonetemperature/#properties
|
||||
FFWmiQuery query(L"SELECT CurrentTemperature, CriticalTripPoint FROM MSAcpi_ThermalZoneTemperature WHERE Active = TRUE", nullptr, FFWmiNamespace::WMI);
|
||||
if(!query)
|
||||
return "Query WMI service failed";
|
||||
|
||||
if(FFWmiRecord record = query.next())
|
||||
{
|
||||
if (current && record.getReal(L"CurrentTemperature", current)) // In tenth of degrees Kelvin
|
||||
*current = *current / 10 - 273.15;
|
||||
if (critical && record.getReal(L"CriticalTripPoint", critical)) // In tenth of degrees Kelvin
|
||||
*critical = *critical / 10 - 273.15;
|
||||
}
|
||||
|
||||
return "No WMI result returned";
|
||||
}
|
8
src/detection/temps/temps_windows.h
Normal file
8
src/detection/temps/temps_windows.h
Normal file
@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef FF_INCLUDED_detection_temps_windows
|
||||
#define FF_INCLUDED_detection_temps_windows
|
||||
|
||||
const char* ffDetectSmbiosTemp(double* current, double* critical);
|
||||
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user