mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-29 16:26:39 +01:00
WMTheme: add support for WIndows
This commit is contained in:
+1
-1
@@ -317,7 +317,7 @@ if(WIN_MSYS)
|
||||
src/detection/displayserver/displayserver_windows.c
|
||||
src/detection/terminalfont/terminalfont_linux.c
|
||||
src/detection/media/media_linux.c
|
||||
src/detection/wmtheme/wmtheme_linux.c
|
||||
src/detection/wmtheme/wmtheme_windows.c
|
||||
src/detection/font/font_linux.c
|
||||
src/detection/opengl/opengl_windows.c
|
||||
src/util/windows/wmi.cpp
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
#include "fastfetch.h"
|
||||
#include "wmtheme.h"
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN 1
|
||||
#include <Windows.h>
|
||||
|
||||
bool ffDetectWmTheme(FFinstance* instance, FFstrbuf* themeOrError)
|
||||
{
|
||||
FF_UNUSED(instance);
|
||||
|
||||
HKEY hKey;
|
||||
if(RegOpenKeyExW(HKEY_CURRENT_USER, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", 0, KEY_READ, &hKey) != ERROR_SUCCESS)
|
||||
{
|
||||
ffStrbufAppendS(themeOrError, "RegOpenKeyExW() failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool result = true;
|
||||
int SystemUsesLightTheme = 1;
|
||||
DWORD bufSize = sizeof(SystemUsesLightTheme);
|
||||
|
||||
if(RegQueryValueExW(hKey, L"SystemUsesLightTheme", NULL, NULL, (LPBYTE)&SystemUsesLightTheme, &bufSize) != ERROR_SUCCESS)
|
||||
{
|
||||
ffStrbufAppendS(themeOrError, "RegOpenKeyExW(SystemUsesLightTheme) failed");
|
||||
goto exit;
|
||||
}
|
||||
|
||||
int AppsUsesLightTheme = 1;
|
||||
bufSize = sizeof(AppsUsesLightTheme);
|
||||
if(RegQueryValueExW(hKey, L"AppsUseLightTheme", NULL, NULL, (LPBYTE)&AppsUsesLightTheme, &bufSize) != ERROR_SUCCESS)
|
||||
{
|
||||
ffStrbufAppendS(themeOrError, "RegOpenKeyExW(AppsUseLightTheme) failed");
|
||||
goto exit;
|
||||
}
|
||||
|
||||
ffStrbufAppendF(themeOrError, "System - %s, Apps - %s", SystemUsesLightTheme ? "Light" : "Dark", AppsUsesLightTheme ? "Light" : "Dark");
|
||||
|
||||
exit:
|
||||
RegCloseKey(hKey);
|
||||
return result;
|
||||
}
|
||||
Reference in New Issue
Block a user