diff --git a/lib/libimhex/include/hex/helpers/utils_macos.hpp b/lib/libimhex/include/hex/helpers/utils_macos.hpp index 8a3b3b055..b5ae40345 100644 --- a/lib/libimhex/include/hex/helpers/utils_macos.hpp +++ b/lib/libimhex/include/hex/helpers/utils_macos.hpp @@ -5,5 +5,6 @@ #include extern "C" void openWebpageMacos(const char *url); + extern "C" bool isMacosSystemDarkModeEnabled(); #endif \ No newline at end of file diff --git a/lib/libimhex/source/helpers/utils_macos.m b/lib/libimhex/source/helpers/utils_macos.m index a1799ff04..b68a52b0d 100644 --- a/lib/libimhex/source/helpers/utils_macos.m +++ b/lib/libimhex/source/helpers/utils_macos.m @@ -13,4 +13,15 @@ CFRelease(urlRef); } + bool isMacosSystemDarkModeEnabled() { + NSString * appleInterfaceStyle = [[NSUserDefaults standardUserDefaults] stringForKey:@"AppleInterfaceStyle"]; + + if (appleInterfaceStyle && [appleInterfaceStyle length] > 0) { + return [[appleInterfaceStyle lowercaseString] containsString:@"dark"]; + } else { + return false; + } + } +} + #endif \ No newline at end of file diff --git a/main/source/window/linux_window.cpp b/main/source/window/linux_window.cpp index 5cd581e38..ba58d0981 100644 --- a/main/source/window/linux_window.cpp +++ b/main/source/window/linux_window.cpp @@ -38,7 +38,7 @@ namespace hex { auto exitCode = WEXITSTATUS(pclose(pipe)); if (exitCode != 0) return; - EventManager::post(hex::containsIgnoreCase(result, "dark") ? 1 : 2); + EventManager::post(hex::containsIgnoreCase(result, "light") ? 2 : 1); }); if (themeFollowSystem) diff --git a/main/source/window/macos_window.cpp b/main/source/window/macos_window.cpp index b44f6f9a4..efcf4968c 100644 --- a/main/source/window/macos_window.cpp +++ b/main/source/window/macos_window.cpp @@ -5,6 +5,7 @@ #include #include + #include #include #include @@ -23,8 +24,10 @@ namespace hex { EventManager::subscribe(this, [themeFollowSystem] { if (!themeFollowSystem) return; - // TODO: Implement this when MacOS build is working again - EventManager::post(1); + if (!isMacosSystemDarkModeEnabled()) + EventManager::post(2); + else + EventManager::post(1); }); if (themeFollowSystem) diff --git a/plugins/windows/source/plugin_windows.cpp b/plugins/windows/source/plugin_windows.cpp index 3f485ee2a..0a8c32a5c 100644 --- a/plugins/windows/source/plugin_windows.cpp +++ b/plugins/windows/source/plugin_windows.cpp @@ -34,6 +34,8 @@ static void detectSystemTheme() { auto error = RegQueryValueEx(hkey, "AppsUseLightTheme", nullptr, nullptr, reinterpret_cast(&value), &size); if (error == ERROR_SUCCESS) { EventManager::post(value == 0 ? 1 : 2); + } else { + EventManager::post(1); } } });