mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2025-02-20 11:43:27 +08:00
Brightness: add support for Windows
This commit is contained in:
parent
85098a6627
commit
476b0495e0
@ -463,7 +463,7 @@ elseif(WIN32)
|
||||
src/detection/battery/battery_windows.c
|
||||
src/detection/bios/bios_windows.c
|
||||
src/detection/board/board_windows.c
|
||||
src/detection/brightness/brightness_nosupport.c
|
||||
src/detection/brightness/brightness_windows.cpp
|
||||
src/detection/chassis/chassis_nosupport.c
|
||||
src/detection/cpu/cpu_windows.c
|
||||
src/detection/cpuUsage/cpuUsage_windows.c
|
||||
|
27
src/detection/brightness/brightness_windows.cpp
Normal file
27
src/detection/brightness/brightness_windows.cpp
Normal file
@ -0,0 +1,27 @@
|
||||
extern "C"
|
||||
{
|
||||
#include "brightness.h"
|
||||
}
|
||||
#include "util/windows/wmi.hpp"
|
||||
|
||||
extern "C"
|
||||
const char* ffDetectBrightness(FFlist* result)
|
||||
{
|
||||
FFWmiQuery query(L"SELECT CurrentBrightness, InstanceName FROM WmiMonitorBrightness WHERE Active = true", nullptr, FFWmiNamespace::WMI);
|
||||
if(!query)
|
||||
return "Query WMI service failed";
|
||||
|
||||
while(FFWmiRecord record = query.next())
|
||||
{
|
||||
FFBrightnessResult* display = (FFBrightnessResult*) ffListAdd(result);
|
||||
ffStrbufInit(&display->name);
|
||||
record.getString(L"InstanceName", &display->name);
|
||||
ffStrbufSubstrAfterFirstC(&display->name, '\\');
|
||||
ffStrbufSubstrBeforeFirstC(&display->name, '\\');
|
||||
|
||||
uint64_t brightness;
|
||||
record.getUnsigned(L"CurrentBrightness", &brightness);
|
||||
display->value = (float) brightness;
|
||||
}
|
||||
return NULL;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user